Skip to content

Commit

Permalink
Fix Python 3 test failure introduced in a78dd10.
Browse files Browse the repository at this point in the history
  • Loading branch information
carljm committed Sep 9, 2012
1 parent ffe8bc0 commit 75ef980
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions django/contrib/auth/decorators.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def _wrapped_view(request, *args, **kwargs):
if test_func(request.user): if test_func(request.user):
return view_func(request, *args, **kwargs) return view_func(request, *args, **kwargs)
path = request.build_absolute_uri() 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 # If the login url is the same scheme and net location then just
# use the path as the "next" url. # use the path as the "next" url.
login_scheme, login_netloc = urlparse(resolved_login_url)[:2] login_scheme, login_netloc = urlparse(resolved_login_url)[:2]
Expand All @@ -33,7 +35,8 @@ def _wrapped_view(request, *args, **kwargs):
(not login_netloc or login_netloc == current_netloc)): (not login_netloc or login_netloc == current_netloc)):
path = request.get_full_path() path = request.get_full_path()
from django.contrib.auth.views import redirect_to_login 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 _wrapped_view
return decorator return decorator


Expand Down

0 comments on commit 75ef980

Please sign in to comment.