Skip to content

Commit

Permalink
Django 1.10 compatability (#43)
Browse files Browse the repository at this point in the history
* Changed MIDDLEWARE_CLASSES to MIDDLEWARE for Django 1.10
  • Loading branch information
simonmward authored and mikebryant committed Aug 24, 2017
1 parent 1f49cad commit 44025bb
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions django_autoconfig/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
'''Autoconfig data for applications that don't support this protocol.'''

from collections import namedtuple

import django
from django_autoconfig.autoconfig import OrderingRelationship

Autoconfig = namedtuple('Autoconfig', ('SETTINGS', 'DEFAULT_SETTINGS', 'RELATIONSHIPS'))
if django.VERSION < (1, 10):
middleware_key = 'MIDDLEWARE_CLASSES'
else:
middleware_key = 'MIDDLEWARE'

CONTRIB_CONFIGS = {
'django.contrib.auth': Autoconfig(
Expand All @@ -13,14 +17,14 @@
'django.contrib.contenttypes',
'django.contrib.sessions',
],
'MIDDLEWARE_CLASSES': [
middleware_key: [
'django.contrib.auth.middleware.AuthenticationMiddleware',
],
},
DEFAULT_SETTINGS = {},
RELATIONSHIPS = [
OrderingRelationship(
'MIDDLEWARE_CLASSES',
middleware_key,
'django.contrib.auth.middleware.AuthenticationMiddleware',
after = [
'django.middleware.common.CommonMiddleware',
Expand All @@ -36,7 +40,7 @@
'INSTALLED_APPS': [
'django.contrib.sessions',
],
'MIDDLEWARE_CLASSES': [
middleware_key: [
'django.contrib.messages.middleware.MessageMiddleware',
],
'TEMPLATE_CONTEXT_PROCESSORS': [
Expand All @@ -56,7 +60,7 @@
DEFAULT_SETTINGS = {},
RELATIONSHIPS = [
OrderingRelationship(
'MIDDLEWARE_CLASSES',
middleware_key,
'django.contrib.messages.middleware.MessageMiddleware',
after = [
'django.contrib.sessions.middleware.SessionMiddleware',
Expand All @@ -68,14 +72,14 @@
),
'django.contrib.sessions': Autoconfig(
SETTINGS = {
'MIDDLEWARE_CLASSES': [
middleware_key: [
'django.contrib.sessions.middleware.SessionMiddleware',
],
},
DEFAULT_SETTINGS = {},
RELATIONSHIPS = [
OrderingRelationship(
'MIDDLEWARE_CLASSES',
middleware_key,
'django.contrib.sessions.middleware.SessionMiddleware',
after = [
'django.middleware.cache.UpdateCacheMiddleware',
Expand Down

0 comments on commit 44025bb

Please sign in to comment.