针对Error: You must either define the environment variable DJANGO_SETTINGS_MODULE ...问题的解决
2017-04-28 11:19
585 查看
针对Error: You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings问题的解决
使用intelliJ Idea开发django项目,启动 manage.py 测试时,会出现如上所示问题。根据提示,有两种解决方法:
define the environment variable DJANGO_SETTINGS_MODULE
在manage.py文件中添加
import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "你的project.settings")
call settings.configure() before accessing settings
manage.py文件中添加
from django.conf import settings settings.configure(DEBUG=True)
添加完代码后,检查是否修改项目的project structure设置
Project structure->Facets->Django->
django project root: ##你的django项目路径 settings: ##你的settings.py文件路径 manage.py script: ##manage.py Environment variables: ##添写需要的环境变量
相关文章推荐
- django 解决: You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.c
- Requested setting DATABASES, but settings are not configured. You must either define the environment
- ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined.
- django模板报错Requested setting TEMPLATE_DEBUG, but settings are not configured. You must either define
- django模板报错:Requested setting TEMPLATE_DEBUG, but settings are not configured. You must either define
- ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined. 错误解决方法
- ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is un
- 嵌套Fragment的使用及遇到The specified child already has a parent. You must call removeView()问题的解决
- window下Django第三方APP调用PIL生成验证码出现ImportError: The _imagingft C module is not installed解决
- 2个问题,解决tomcat启动一闪而过和运行tomcat/bin目录下的startup.bat时报错(the CATALINA_HOME environment variable is not defined correctly)
- 嵌套Fragment的使用及遇到The specified child already has a parent. You must call removeView()问题的解决
- 解决The environment variable JAVA_HOME does not point to a valid JVM installation 问题
- 嵌套Fragment的使用及遇到The specified child already has a parent. You must call removeView()问题的解决
- Meteor Error: Must pass options.rootUrl or set ROOT_URL in the server environment解决
- 解决安装VC6.0的问题—you must first run the installation wizard before running the setup
- 嵌套Fragment的使用及遇到The specified child already has a parent. You must call removeView()问题的解决
- The connection to adb is down, and a severe error has occured. You must restart adb and Eclipse.解决办法
- Reader PCSC Driver Error!You Must Reinstall Reader Driver!问题的解决办法
- mount: You must specify the filesystem type问题解决
- 解决viewpaper与frament时出现的The specified child already has a parent. You must call removeView()问题