[英]Django 3 run server error improperly configured on django 3
I installed the newest version of Django and when I did the runserver command it showed a really long error.我安装了最新版本的 Django,当我执行 runserver 命令时,它显示了一个很长的错误。 I searched the internet for it but most of the solutions I found were either not working or outdated.
我在互联网上搜索了它,但我发现的大多数解决方案要么不起作用,要么已经过时。
The error:错误:
django.core.exceptions.ImproperlyConfigured:
django.core.exceptions.ImproperlyConfigured:
Requested setting DEBUG, but settings are not configured.请求设置 DEBUG,但未配置设置。 You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
您必须在访问设置之前定义环境变量 DJANGO_SETTINGS_MODULE 或调用 settings.configure()。
Please help me as I have been stuck on this for a really long time.请帮助我,因为我已经坚持了很长时间。
Thanks谢谢
wsgi.py
should look like this considering your project name is yourProject
:考虑到您的项目名称是
yourProject
, wsgi.py
应该看起来像这样:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'yourProject.settings')
application = get_wsgi_application()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.