diff --git a/django/contrib/auth/decorators.py b/django/contrib/auth/decorators.py
index 9b2504b..dbc10ab 100644
a
|
b
|
def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIE
|
21 | 21 | if test_func(request.user): |
22 | 22 | return view_func(request, *args, **kwargs) |
23 | 23 | path = request.build_absolute_uri() |
24 | | resolved_login_url = resolve_url(login_url or settings.LOGIN_URL) |
| 24 | resolved_login_url = resolve_url(login_url or settings.LOGIN_URL, *args, **kwargs) |
25 | 25 | # If the login url is the same scheme and net location then just |
26 | 26 | # use the path as the "next" url. |
27 | 27 | login_scheme, login_netloc = urlparse(resolved_login_url)[:2] |
diff --git a/tests/urlpatterns_reverse/reverse_lazy_urls.py b/tests/urlpatterns_reverse/reverse_lazy_urls.py
index 694b23f..8ab7f97 100644
a
|
b
|
from .views import LazyRedirectView, empty_view, login_required_view
|
5 | 5 | urlpatterns = [ |
6 | 6 | url(r'^redirected_to/$', empty_view, name='named-lazy-url-redirected-to'), |
7 | 7 | url(r'^login/$', empty_view, name='some-login-page'), |
8 | | url(r'^login_required_view/$', login_required_view), |
| 8 | url(r'^(\d{4})/login_required_view/$', login_required_view), |
9 | 9 | url(r'^redirect/$', LazyRedirectView.as_view()), |
10 | 10 | ] |
diff --git a/tests/urlpatterns_reverse/tests.py b/tests/urlpatterns_reverse/tests.py
index f7f8fcc..ea76258 100644
a
|
b
|
class ReverseLazyTest(TestCase):
|
317 | 317 | |
318 | 318 | def test_user_permission_with_lazy_reverse(self): |
319 | 319 | User.objects.create_user('alfred', 'alfred@example.com', password='testpw') |
320 | | response = self.client.get('/login_required_view/') |
321 | | self.assertRedirects(response, "/login/?next=/login_required_view/", status_code=302) |
| 320 | response = self.client.get('/1986/login_required_view/') |
| 321 | self.assertRedirects(response, "/login/?next=/1986/login_required_view/", status_code=302) |
322 | 322 | self.client.login(username='alfred', password='testpw') |
323 | 323 | response = self.client.get('/login_required_view/') |
324 | 324 | self.assertEqual(response.status_code, 200) |
diff --git a/tests/urlpatterns_reverse/views.py b/tests/urlpatterns_reverse/views.py
index 9fd2ad1..e0a04ef 100644
a
|
b
|
class LazyRedirectView(RedirectView):
|
49 | 49 | url = reverse_lazy('named-lazy-url-redirected-to') |
50 | 50 | |
51 | 51 | |
52 | | @user_passes_test(lambda u: u.is_authenticated(), login_url=reverse_lazy('some-login-page')) |
| 52 | @user_passes_test(lambda u: u.is_authenticated(), login_url='some-login-page') |
53 | 53 | def login_required_view(request): |
54 | 54 | return HttpResponse('Hello you') |
55 | 55 | |