diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py index 9f447155ae9..524710327a2 100644 --- a/django/contrib/auth/views.py +++ b/django/contrib/auth/views.py @@ -1,12 +1,13 @@ +from django import oldforms +from django.contrib.auth import REDIRECT_FIELD_NAME +from django.contrib.auth.decorators import login_required from django.contrib.auth.forms import AuthenticationForm from django.contrib.auth.forms import PasswordResetForm, PasswordChangeForm -from django import oldforms -from django.shortcuts import render_to_response -from django.template import RequestContext from django.contrib.sites.models import Site, RequestSite from django.http import HttpResponseRedirect -from django.contrib.auth.decorators import login_required -from django.contrib.auth import REDIRECT_FIELD_NAME +from django.shortcuts import render_to_response +from django.template import RequestContext +from django.utils.http import urlquote from django.utils.translation import ugettext as _ def login(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME): @@ -62,7 +63,7 @@ def redirect_to_login(next, login_url=None, redirect_field_name=REDIRECT_FIELD_N if not login_url: from django.conf import settings login_url = settings.LOGIN_URL - return HttpResponseRedirect('%s?%s=%s' % (login_url, redirect_field_name, next)) + return HttpResponseRedirect('%s?%s=%s' % (login_url, urlquote(redirect_field_name), urlquote(next))) def password_reset(request, is_admin_site=False, template_name='registration/password_reset_form.html', email_template_name='registration/password_reset_email.html'):