Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

[py3] fixed __proxy__.decode doesn't exists on django/contrib/auth/de…

  • Loading branch information...
commit 22987ddf66ed2af39b8df920e3e8501af8782819 1 parent b1f18e9
@Natim Natim authored
Showing with 9 additions and 2 deletions.
  1. +9 −2 django/contrib/auth/
11 django/contrib/auth/
@@ -7,6 +7,7 @@
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.core.exceptions import PermissionDenied
from django.utils.decorators import available_attrs
+from django.utils import six
def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME):
@@ -22,15 +23,21 @@ def _wrapped_view(request, *args, **kwargs):
if test_func(request.user):
return view_func(request, *args, **kwargs)
path = request.build_absolute_uri()
+ _login_url = None
+ if login_url is not None:
+ if six.PY3:
+ _login_url = str(login_url)
+ else:
+ _login_url = unicode(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(login_url or settings.LOGIN_URL)[:2]
+ login_scheme, login_netloc = urlparse(_login_url or settings.LOGIN_URL)[:2]
current_scheme, current_netloc = urlparse(path)[:2]
if ((not login_scheme or login_scheme == current_scheme) and
(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, _login_url, redirect_field_name)
return _wrapped_view
return decorator

0 comments on commit 22987dd

Please sign in to comment.
Something went wrong with that request. Please try again.