summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2007-09-14 19:25:37 +0000
committerAdrian Holovaty <adrian@holovaty.com>2007-09-14 19:25:37 +0000
commit55d6aebfecb527d64f50e608bb51cb5ea81f4c62 (patch)
treef5dd5813af21237009c86a191364feca1236ead0 /docs
parent0d52d2b2f90ea12c2ca721a46052b0c17bae3b47 (diff)
Fixed #5394 -- REDIRECT_FIELD_NAME is now configurable. Thanks, Petr Marhoun, DavidReynolds and effbot
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6206 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
-rw-r--r--docs/authentication.txt20
1 files changed, 19 insertions, 1 deletions
diff --git a/docs/authentication.txt b/docs/authentication.txt
index 131a8930b5..820aff2712 100644
--- a/docs/authentication.txt
+++ b/docs/authentication.txt
@@ -402,11 +402,29 @@ introduced in Python 2.4::
def my_view(request):
# ...
+In the Django development version, ``login_required`` also takes an optional
+``redirect_field_name`` parameter. Example::
+
+ from django.contrib.auth.decorators import login_required
+
+ def my_view(request):
+ # ...
+ my_view = login_required(redirect_field_name='redirect_to')(my_view)
+
+Again, an equivalent example of the more compact decorator syntax introduced in Python 2.4::
+
+ from django.contrib.auth.decorators import login_required
+
+ @login_required(redirect_field_name='redirect_to')
+ def my_view(request):
+ # ...
+
``login_required`` does the following:
* If the user isn't logged in, redirect to ``settings.LOGIN_URL``
(``/accounts/login/`` by default), passing the current absolute URL
- in the query string as ``next``. For example:
+ in the query string as ``next`` or the value of ``redirect_field_name``.
+ For example:
``/accounts/login/?next=/polls/3/``.
* If the user is logged in, execute the view normally. The view code is
free to assume the user is logged in.