summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-11-26 07:20:07 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-11-26 07:20:07 +0000
commit8128f440ee74dd72f9204f657f6180a128dc8eaf (patch)
treea620402555e4bdd5b5c00295b21f536bb4a08736 /docs
parentd058a8a104e01d76bd68443787a47a3b58a9913a (diff)
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
Diffstat (limited to 'docs')
-rw-r--r--docs/authentication.txt20
1 files changed, 20 insertions, 0 deletions
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
--------------------------------