From 7d0fa02dc05ec9f1f398e870066ae8d2c717d5de Mon Sep 17 00:00:00 2001 From: Xavier Ordoquy Date: Mon, 6 Nov 2017 15:23:54 +0100 Subject: [PATCH] Revert "Move django.contrib.auth import out of compat." This reverts commit d4d9cc1d53fa38fdf6b38e2a64b4aa3a71a9760c. --- rest_framework/compat.py | 9 +++++++++ rest_framework/urls.py | 11 +---------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/rest_framework/compat.py b/rest_framework/compat.py index 456c8b20d..ce821402e 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -11,6 +11,7 @@ import inspect import django from django.apps import apps from django.conf import settings +from django.contrib.auth import views from django.core.exceptions import ImproperlyConfigured, ValidationError from django.core.validators import \ MaxLengthValidator as DjangoMaxLengthValidator @@ -333,3 +334,11 @@ def authenticate(request=None, **credentials): else: return authenticate(request=request, **credentials) +if django.VERSION < (1, 11): + login = views.login + login_kwargs = {'template_name': 'rest_framework/login.html'} + logout = views.logout +else: + login = views.LoginView.as_view(template_name='rest_framework/login.html') + login_kwargs = {} + logout = views.LogoutView.as_view() diff --git a/rest_framework/urls.py b/rest_framework/urls.py index 1ab5fad61..60107d4d2 100644 --- a/rest_framework/urls.py +++ b/rest_framework/urls.py @@ -15,17 +15,8 @@ and you should make sure your authentication settings include `SessionAuthentica from __future__ import unicode_literals from django.conf.urls import url -from django.contrib.auth import views - -if django.VERSION < (1, 11): - login = views.login - login_kwargs = {'template_name': 'rest_framework/login.html'} - logout = views.logout -else: - login = views.LoginView.as_view(template_name='rest_framework/login.html') - login_kwargs = {} - logout = views.LogoutView.as_view() +from rest_framework.compat import login, login_kwargs, logout app_name = 'rest_framework' urlpatterns = [