django.core.exceptions.ImproperlyConfigured:。您必须定义环境变量DJANGO_SETTINGS_MODULE

时间:2019-11-03 07:26:31

标签: python django

我将应用程序设为jecommerce。得到 django.core.exceptions.ImproperlyConfigured:请求的设置INSTALLED_APPS,但未配置设置。在访问urls.py中的设置之前,您必须定义环境变量DJANGO_SETTINGS_MODULE或调用settings.configure()。这是我的代码

from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls), 
    path('accounts/', include('allauth.urls')),
]

if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL,
                          document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL,
                          document_root=settings.MEDIA_ROOT) 

0 个答案:

没有答案