[Django]-Custom settings and wsgi in django 1.10 give me error

13👍

try changing the MIDDLEWARE_CLASSES

MIDDLEWARE_CLASSES = [
    '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',
    'django.middleware.security.SecurityMiddleware',
]

14👍

I had a similar problem with when upgrading my app to django 1.10. First I would try changing MIDDLEWARE_CLASSES to MIDDLEWARE because with Django 1.10 they introduced a new style of middleware outline here:

https://docs.djangoproject.com/en/1.10/releases/1.10/

If that doesn’t work, I would suggest checking your django middleware files, I had to change all classes that took object to MiddlewareMixin which you can import by calling:

from django.utils.deprecation import MiddlewareMixin

In my case I changed

class SiteMiddleware(object):
...

to

from django.utils.deprecation import MiddlewareMixin

class SiteMiddleware(MiddlewareMixin):
...

2👍

I tried directly in Django 1.10! Initially it showed
“TypeError: object() takes no parameters” error.
After I changed MIDDLEWARE to MIDDLEWARE_CLASSES in my settings.py, it worked!

👤8I8

1👍

I would add that in addition to what mol mentioned, during process of upgrading Django I had to temporary disable the linked virtual host. Also try freshly upgrading to Django 1.10 (uninstall Django 1.9, then install Django 1.10).

You might need to additionally clear all Django sessions as well.

Leave a comment