From 8128f440ee74dd72f9204f657f6180a128dc8eaf Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sat, 26 Nov 2005 07:20:07 +0000 Subject: Fixed #903 -- Added login_url argument to user_passes_test view decorator. Didn't add it to login_required decorator because that would turn login_required into a callable decorator, which would break backwards compatibility. git-svn-id: http://code.djangoproject.com/svn/django/trunk@1440 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/authentication.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'docs') diff --git a/docs/authentication.txt b/docs/authentication.txt index c1d8694499..d31e2ced79 100644 --- a/docs/authentication.txt +++ b/docs/authentication.txt @@ -314,6 +314,26 @@ Here's the same thing, using Python 2.4's decorator syntax:: Note that ``user_passes_test`` does not automatically check that the ``User`` is not anonymous. +**New in the Django development version**: ``user_passes_test()`` takes an +optional ``login_url`` argument, which lets you specify the URL for your login +page (``/accounts/login/`` by default). + +Example in Python 2.3 syntax:: + + from django.views.decorators.auth import user_passes_test + + def my_view(request): + # ... + my_view = user_passes_test(lambda u: u.has_perm('polls.can_vote'), login_url='/login/')(my_view) + +Example in Python 2.4 syntax:: + + from django.views.decorators.auth import user_passes_test + + @user_passes_test(lambda u: u.has_perm('polls.can_vote'), login_url='/login/') + def my_view(request): + # ... + Limiting access to generic views -------------------------------- -- cgit v1.3