Django NotperlyConfigured: WSGI application "myproject.wsgi.application" cannot be loaded; Error Import Module

I have an almost new django installation, and when I try to execute python manage.py runningerver.It gives me this error:

Incorrect Configured: WSGI application "myproject.wsgi.application" could not be loaded; Error import module.

settings.py

WSGI_APPLICATION = 'myproject.wsgi.application' 

wsgi.py

 import os from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings") application = get_wsgi_application() 
+8
source share
6 answers

Comment out

# 'Django.contrib.auth.middleware.SessionAuthenticationMiddleware',

in your settings.py file in Middleware

+9
source

Based on my experience, this happens when I try to run runserver, but I have not set all custom MIDDLEWARE to setting.py. After defining and installing the middleware, the error is resolved.

+2
source

Check the stack trace - you can find the answer a few lines above the line "The above exception was the direct cause of the following exception:"

This can be caused, for example, by using middleware from an uninstalled third-party application, etc.

+1
source

I ran into the same problem because I added the debug_toolbar middleware to my settings.py

 'debug_toolbar.middleware.DebugToolbarMiddleware', 

I solved the problem by uninstalling the debug_toolbar middleware. I also had to remove debug_toolbar from my installed applications.

+1
source

Check settings.py,

 MIDDLEWARE=[ 'whitenoise.middleware.WhiteNoiseMiddleware', ] 

remove 'whitenoise.middleware.WhiteNoiseMiddleware', or install Whitenoise ( pip install whitenoise )

+1
source

For whitenoise version 4.0 or higher: - Removed the WSGI integration option for Django (which included editing wsgi.py). Instead, you should add WhiteNoise to your middleware list in settings.py and remove any WhiteNoise link from wsgi.py.

 MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'whitenoise.middleware.WhiteNoiseMiddleware', # ... ] 
  • The alias 'whitenoise.django.GzipManifestStaticFilesStorage' now deleted. Instead, you should use the correct import path: 'whitenoise.storage.CompressedManifestStaticFilesStorage' .
0
source

Source: https://habr.com/ru/post/1274051/


All Articles