mirror of
https://github.com/django/django.git
synced 2025-06-05 03:29:12 +00:00
[1.9.x] Fixed #25169 -- Documented stacking of permission_required and login_required.
Backport of 9788625277b85596302bbf2c39cf829b7a766a4f from master
This commit is contained in:
parent
16865782d7
commit
8e23527075
@ -688,6 +688,17 @@ The ``permission_required`` decorator
|
||||
(HTTP Forbidden) view<http_forbidden_view>` instead of redirecting to the
|
||||
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.9
|
||||
|
||||
In older versions, the ``permission`` parameter only worked with
|
||||
|
Loading…
x
Reference in New Issue
Block a user