summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2012-09-09 11:37:16 -0600
committerCarl Meyer <carl@oddbird.net>2012-09-09 11:37:21 -0600
commit75ef980e20fc0441aedb0645aa471c9fe606e3b0 (patch)
tree824ce4f9da345bd2ef7824cebea0cb675f30749a
parentffe8bc00bf9b94a366ea3d1998a2712a908a9f1b (diff)
Fix Python 3 test failure introduced in a78dd109.
-rw-r--r--django/contrib/auth/decorators.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/django/contrib/auth/decorators.py b/django/contrib/auth/decorators.py
index 0fc9f3754a..11518193e7 100644
--- a/django/contrib/auth/decorators.py
+++ b/django/contrib/auth/decorators.py
@@ -24,7 +24,9 @@ def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIE
if test_func(request.user):
return view_func(request, *args, **kwargs)
path = request.build_absolute_uri()
- resolved_login_url = resolve_url(login_url or settings.LOGIN_URL)
+ # urlparse chokes on lazy objects in Python 3, force to str
+ resolved_login_url = force_str(
+ resolve_url(login_url or settings.LOGIN_URL))
# If the login url is the same scheme and net location then just
# use the path as the "next" url.
login_scheme, login_netloc = urlparse(resolved_login_url)[:2]
@@ -33,7 +35,8 @@ def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIE
(not login_netloc or login_netloc == current_netloc)):
path = request.get_full_path()
from django.contrib.auth.views import redirect_to_login
- return redirect_to_login(path, login_url, redirect_field_name)
+ return redirect_to_login(
+ path, resolved_login_url, redirect_field_name)
return _wrapped_view
return decorator