11👍
From my experience this happens when I try to execute runserver but I haven’t installed all custom MIDDLEWARE in setting.py. After identifying and installing the middlewares the error is resolved.
18👍
Comment out the
#’django.contrib.auth.middleware.SessionAuthenticationMiddleware’,
in your settings.py file in Middleware
7👍
Check the settings.py,
MIDDLEWARE=[
'whitenoise.middleware.WhiteNoiseMiddleware',
]
remove 'whitenoise.middleware.WhiteNoiseMiddleware',
or install Whitenoise (pip install whitenoise)
- Django Test — Unable to drop and recreate test database
- Django fixtures not accepting YAML?
- Django testing: Got an error creating the test database: database "database_name" already exists
- How does use_for_related_fields work in Django?
- Django Whitenoise 500 server error in non debug mode
4👍
Check for the stack trace – you might find answer few lines above the line “The above exception was the direct cause of the following exception:”
It may caused for example by using of middleware from some uninstalled third party app etc.
4👍
One of the reason for this issue is if you have a middleware added into django middleware list in settings.py but haven’t installed it yet.
In my case I added corsheaders.middleware.CorsMiddleware
which wasn’t installed.I installed it using pip install django-cors-headers
and that did the trick.
- How to add an initial/default value using Django Filters?
- X-editable inline editing in Django – how to get CSRF protection?
1👍
I encountered the same problem because I added the debug_toolbar Middleware to my settings.py
'debug_toolbar.middleware.DebugToolbarMiddleware',
I solved the problem by removing the debug_toolbar Middleware. I also had to remove debug_toolbar from my INSTALLED APPS.
1👍
For whitenoise version 4.0
or above:
– The WSGI integration option for Django (which involved editing wsgi.py) has been removed. Instead, you should add WhiteNoise to your middleware list in settings.py and remove any reference to WhiteNoise from wsgi.py.
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
# ...
]
- The
'whitenoise.django.GzipManifestStaticFilesStorage'
alias has now been removed. Instead you should use the correct import path:'whitenoise.storage.CompressedManifestStaticFilesStorage'
.
1👍
for anyone having this same issue. i just fixed it following the instructions here
you should add WhiteNoise to your middleware list in settings.py and remove any reference to WhiteNoise from wsgi.py.
0👍
I had the same error, and in my case, I had made a custom middleware and then added it to the middleware list in settings.py
under MIDDLEWARE
. The problem was in the casing that I had used for listing the middleware in the list. I changed it to match the casing of my custom one and it worked!
- How to display "This many months ago" in Django using Humanize?
- How to efficiently serve massive sitemaps in django
- Fabric – sudo -u
- How to give initial value in modelform
0👍
got the same error when mistakenly registering a app in MIDDLEWARE = [] insted of INSTALLED_APPS = []
- Django 'function' object has no attribute 'objects'
- How to access RequestContext in class-based generic views?
- Model self-dependency (one-to-many field) implementation