diff options
| author | Bryan Marty <bryanmarty@gmail.com> | 2015-10-30 13:26:09 -0700 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-11-12 14:25:29 -0500 |
| commit | 8e23527075b15704451e3d51bf776e3fda8b09e7 (patch) | |
| tree | 3b8c39da07dca9da232081b49fbf1a132d398ed4 /docs | |
| parent | 16865782d7d92c863bcb62e2e91400dd8af79c5b (diff) | |
[1.9.x] Fixed #25169 -- Documented stacking of permission_required and login_required.
Backport of 9788625277b85596302bbf2c39cf829b7a766a4f from master
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/topics/auth/default.txt | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/docs/topics/auth/default.txt b/docs/topics/auth/default.txt index 386b9ca6b5..67d843a017 100644 --- a/docs/topics/auth/default.txt +++ b/docs/topics/auth/default.txt @@ -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 |
