浏览代码

Fixed #25169 -- Documented stacking of permission_required and login_required.

Bryan Marty 9 年之前
父节点
当前提交
9788625277
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      docs/topics/auth/default.txt

+ 11 - 0
docs/topics/auth/default.txt

@@ -687,6 +687,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