发布时间:2024-09-12 14:01
django报错:
Eclipse pydev 运行不出错,cmd 命令行界面中python 运行出错:
django.core.exceptions.ImproperlyConfigured:
Requested setting DATABASES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call
settings.configure() before accessing settings.
解决方法一:
Main代码中增加;
import os
os.environ[\'DJANGO_SETTINGS_MODULE\'] = \'mysite.settings\'
解决方法二:
命令行运行程序之前运行以下命令或者在bat 批处理文件中增加这句话;
set DJANGO_SETTINGS_MODULE=mysite.settings