              redirect_to = resolve_url(redirect_to)
  
              # Heavier security check -- don't allow redirection to a different
              # host.
              if netloc and netloc != request.get_host():
                  redirect_to = resolve_url(settings.LOGIN_REDIRECT_URL)
 
</s> remove             netloc = urlparse(redirect_to)[1]

 </s> add  </s> remove             # urlparse chokes on lazy objects in Python 3
            login_url_as_str = force_str(login_url or settings.LOGIN_URL)
 </s> add             resolved_login_url = resolve_url(login_url or settings.LOGIN_URL) </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     def testLoginRequired(self, view_url='/login_required/', login_url=settings.LOGIN_URL):
 </s> add     def testLoginRequired(self, view_url='/login_required/', login_url='/login/'):
            netloc = urlparse(redirect_to)[1]
              redirect_to = resolve_url(redirect_to)
  
            netloc = urlparse(redirect_to)[1]
              # Heavier security check -- don't allow redirection to a different
              # host.
              if netloc and netloc != request.get_host():
                  redirect_to = resolve_url(settings.LOGIN_REDIRECT_URL)
keep add 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/views.py