Django设置启动环境

编程

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.参考

  • 【Django】settings(django中settings设置)

以上是 Django设置启动环境 的全部内容, 来源链接: utcz.com/z/511012.html

回到顶部