diff --git a/axes/decorators.py b/axes/decorators.py index ad1353c..110e579 100644 --- a/axes/decorators.py +++ b/axes/decorators.py @@ -5,7 +5,6 @@ from datetime import timedelta from django.conf import settings from django.contrib.auth import logout from django.core.exceptions import ObjectDoesNotExist -from django.contrib.auth.models import SiteProfileNotAvailable from django.http import HttpResponse from django.http import HttpResponseRedirect from django.shortcuts import render_to_response @@ -20,6 +19,11 @@ except ImportError: # django < 1.5 else: User = get_user_model() +try: + from django.contrib.auth.models import SiteProfileNotAvailable +except ImportError: # django >= 1.7 + SiteProfileNotAvailable = type('SiteProfileNotAvailable', (Exception,), {}) + from axes.models import AccessLog from axes.models import AccessAttempt from axes.signals import user_locked_out @@ -58,7 +62,6 @@ IP_BLACKLIST = getattr(settings, 'AXES_IP_BLACKLIST', None) ERROR_MESSAGE = ugettext_lazy("Please enter a correct username and password. " "Note that both fields are case-sensitive.") -LOGIN_FORM_KEY = 'this_is_the_login_form' def get_ip(request): diff --git a/axes/tests.py b/axes/tests.py index 895343f..47ce322 100644 --- a/axes/tests.py +++ b/axes/tests.py @@ -5,15 +5,24 @@ import time from django.test import TestCase from django.test.client import Client from django.contrib.auth.models import User +from django.core.urlresolvers import NoReverseMatch from django.core.urlresolvers import reverse from axes.decorators import COOLOFF_TIME from axes.decorators import FAILURE_LIMIT -from axes.decorators import LOGIN_FORM_KEY from axes.models import AccessLog from axes.utils import reset +# Django >= 1.7 compatibility +try: + ADMIN_LOGIN_URL = reverse('admin:login') + LOGIN_FORM_KEY = '