[Django]-Django E.408, E.409 and E.410 errors on runserver

36πŸ‘

βœ…

In Django 2.2.3, activating middlewears in settings is done using the variable MIDDLEWARE not MIDDLEWERE_CLASSES, check the docs here.

So simply change the variable in your settings.py from MIDDLEWARE_CLASSES to MIDDLEWARE.

Most likely this issue occurred due to creating a project with a global django package that had was of version < 2, and then running manage.py runserver with a virtualenv that has local django >= 2

πŸ‘€Nader Alexan

10πŸ‘

Rename variables in settings.py, or add this:

MIDDLEWARE = MIDDLEWARE_CLASSES

to settings.py
because new Django triggers errors above based on checks like this:

if not _contains_subclass(
   'django.contrib.auth.middleware.AuthenticationMiddleware', 
   settings.MIDDLEWARE
):
   errors.append(checks.Error( ...

7πŸ‘

Change setting.py as pic shows
Change setting.py

# MIDDLEWARE_CLASSES = [
MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    # 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

Also See: From CSDN

πŸ‘€cobra8626

5πŸ‘

1) Go to settings.py of your project

2) Cut these three lines from MIDDLEWARE_CLASSES :

    'django.contrib.sessions.middleware.SessionMiddleware', 
    'django.contrib.messages.middleware.MessageMiddleware', 
    'django.contrib.auth.middleware.AuthenticationMiddleware',

3) Now paste the code given below right after MIDDLEWARE_CLASSES :

MIDDLEWARE = [
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
]

Will look like this:
enter image description here

πŸ‘€Faizun Faria

0πŸ‘

change like it and keep the both ke MIDDLEWARE_CLASSES and MIDDLEWARE classes

 MIDDLEWARE_CLASSES = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    # 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

MIDDLEWARE = [
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',  
]

0πŸ‘

If you have a custom middleware, try to import it in manage.py shell. Sometimes Django can blame other middlewares when it cannot import yours (because of not installed dependency for example).

πŸ‘€lampslave

Leave a comment