mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +00:00
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
This commit is contained in:
parent
27265f70a1
commit
bb00b28399
5 changed files with 55 additions and 28 deletions
|
@ -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'),
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue