          def _wrapped_view(request, *args, **kwargs):
              if test_func(request.user):
                  return view_func(request, *args, **kwargs)
              path = request.build_absolute_uri()
              # urlparse chokes on lazy objects in Python 3
              login_url_as_str = force_str(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(login_url_as_str)[:2]
              current_scheme, current_netloc = urlparse(path)[:2]
              if ((not login_scheme or login_scheme == current_scheme) and
 
</s> remove             login_scheme, login_netloc = urlparse(login_url_as_str)[:2]
 </s> add             login_scheme, login_netloc = urlparse(resolved_login_url)[:2] </s> remove             netloc = urlparse(redirect_to)[1]

 </s> add  </s> remove     def testLoginRequired(self, view_url='/login_required/', login_url=settings.LOGIN_URL):
 </s> add     def testLoginRequired(self, view_url='/login_required/', login_url='/login/'):
            resolved_login_url = resolve_url(login_url or settings.LOGIN_URL)
          def _wrapped_view(request, *args, **kwargs):
              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)
            resolved_login_url = 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(login_url_as_str)[:2]
              current_scheme, current_netloc = urlparse(path)[:2]
              if ((not login_scheme or login_scheme == current_scheme) and
keep keep keep keep replace replace keep keep keep keep keep
 Fixed #15552 -- LOGIN_URL and LOGIN_REDIRECT_URL can take URLpattern names.

Thanks UloPe and Eric Florenzano for the patch, and Malcolm Tredinnick for
review. 
django/contrib/auth/decorators.py