Django设置启动环境

徘徊边缘 提交于 2019-11-25 22:16:49

1.命令行指定环境

我们知道正常的django项目都是有多个环境的配置的,在启动时需要指定启动环境,如:

python manage.py runserver --settings=myapp.settings.test

其中的myapp.settings.test对应你的应用的目录级别,test对应的就是test.py

2.Visual Studio Code指定环境

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Django",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/manage.py",
            "args": [
                "runserver",
                "--noreload",
                "--settings=myapp.settings.test"
            ],
            "django": true
        }
    ]
}

3.参考

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!