diff options
| author | Jannis Leidel <jannis@leidel.info> | 2010-09-10 19:38:57 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2010-09-10 19:38:57 +0000 |
| commit | bb00b2839980145984c487410fc65fbc0c94be3d (patch) | |
| tree | d1e0df19d3d6195ac80d149e54e93282879f0859 /docs | |
| parent | 27265f70a18ab8fb4bfacad0cdebe170c342054c (diff) | |
Added login_url argument to login_required decorator. Thanks mhlakhani and ericflo for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@13723 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/topics/auth.txt | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/docs/topics/auth.txt b/docs/topics/auth.txt index 4a6e30fc00..00b95ba085 100644 --- a/docs/topics/auth.txt +++ b/docs/topics/auth.txt @@ -713,6 +713,17 @@ The login_required decorator def my_view(request): ... + .. versionadded:: 1.3 + + :func:`~django.contrib.auth.decorators.login_required` also takes an + optional ``login_url`` parameter. Example:: + + from django.contrib.auth.decorators import login_required + + @login_required(login_url='/accounts/login/') + def my_view(request): + ... + :func:`~django.contrib.auth.decorators.login_required` does the following: * If the user isn't logged in, redirect to @@ -726,9 +737,9 @@ The login_required decorator * If the user is logged in, execute the view normally. The view code is free to assume the user is logged in. -Note that you'll need to map the appropriate Django view to -:setting:`settings.LOGIN_URL <LOGIN_URL>`. For example, using the defaults, add -the following line to your URLconf:: +Note that if you don't specify the ``login_url`` parameter, you'll need to map +the appropriate Django view to :setting:`settings.LOGIN_URL <LOGIN_URL>`. For +example, using the defaults, add the following line to your URLconf:: (r'^accounts/login/$', 'django.contrib.auth.views.login'), |
