Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating to make compatible with later versions of Django #27

Merged
merged 2 commits into from Mar 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions maintenancemode/middleware.py
Expand Up @@ -4,8 +4,13 @@
import django

from django.conf import urls
from django.core import urlresolvers

from django.urls import get_resolver
try:
from django.utils.deprecation import MiddlewareMixin
except ImportError:
# Compatibility for older version of Django
MiddlewareMixin = object

from .conf import settings
from . import utils as maintenance

Expand All @@ -15,7 +20,7 @@
IGNORE_URLS = tuple([re.compile(u) for u in settings.MAINTENANCE_IGNORE_URLS])


class MaintenanceModeMiddleware(object):
class MaintenanceModeMiddleware(MiddlewareMixin):

def process_request(self, request):
# Allow access if middleware is not activated
Expand Down Expand Up @@ -45,7 +50,7 @@ def process_request(self, request):
return None

# Otherwise show the user the 503 page
resolver = urlresolvers.get_resolver(None)
resolver = get_resolver(None)

if django.VERSION < (1, 8):
callback, param_dict = resolver._resolve_special('503')
Expand Down