Skip to content

Commit d4d9cc1

Browse files
committed
Move django.contrib.auth import out of compat.
Fixed some regressions where compat was imported during app loading and led to importing django.contrib.auth.models which ended in a `AppRegistryNotReady` exception.
1 parent 3dc40f9 commit d4d9cc1

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

rest_framework/compat.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import django
1212
from django.apps import apps
1313
from django.conf import settings
14-
from django.contrib.auth import views
1514
from django.core.exceptions import ImproperlyConfigured, ValidationError
1615
from django.core.validators import \
1716
MaxLengthValidator as DjangoMaxLengthValidator
@@ -334,11 +333,3 @@ def authenticate(request=None, **credentials):
334333
else:
335334
return authenticate(request=request, **credentials)
336335

337-
if django.VERSION < (1, 11):
338-
login = views.login
339-
login_kwargs = {'template_name': 'rest_framework/login.html'}
340-
logout = views.logout
341-
else:
342-
login = views.LoginView.as_view(template_name='rest_framework/login.html')
343-
login_kwargs = {}
344-
logout = views.LogoutView.as_view()

rest_framework/urls.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,17 @@
1515
from __future__ import unicode_literals
1616

1717
from django.conf.urls import url
18+
from django.contrib.auth import views
19+
20+
if django.VERSION < (1, 11):
21+
login = views.login
22+
login_kwargs = {'template_name': 'rest_framework/login.html'}
23+
logout = views.logout
24+
else:
25+
login = views.LoginView.as_view(template_name='rest_framework/login.html')
26+
login_kwargs = {}
27+
logout = views.LogoutView.as_view()
1828

19-
from rest_framework.compat import login, login_kwargs, logout
2029

2130
app_name = 'rest_framework'
2231
urlpatterns = [

0 commit comments

Comments
 (0)