[1.8.x] Fixed #25169 -- Documented stacking of permission_required and login_required.
Backport of 9788625277
from master
This commit is contained in:
parent
10d18dec10
commit
16c1075d33
|
@ -592,6 +592,17 @@ The permission_required decorator
|
||||||
(HTTP Forbidden) view<http_forbidden_view>` instead of redirecting to the
|
(HTTP Forbidden) view<http_forbidden_view>` instead of redirecting to the
|
||||||
login page.
|
login page.
|
||||||
|
|
||||||
|
If you want to use ``raise_exception`` but also give your users a chance to
|
||||||
|
login first, you can add the
|
||||||
|
:func:`~django.contrib.auth.decorators.login_required` decorator::
|
||||||
|
|
||||||
|
from django.contrib.auth.decorators import login_required, permission_required
|
||||||
|
|
||||||
|
@permission_required('polls.can_vote', raise_exception=True)
|
||||||
|
@login_required
|
||||||
|
def my_view(request):
|
||||||
|
...
|
||||||
|
|
||||||
.. versionchanged:: 1.7
|
.. versionchanged:: 1.7
|
||||||
|
|
||||||
The :func:`~django.contrib.auth.decorators.permission_required`
|
The :func:`~django.contrib.auth.decorators.permission_required`
|
||||||
|
|
Loading…
Reference in New Issue