File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -209,6 +209,17 @@ This view loads and renders the template ``403.html`` in your root template
209209directory, or if this file does not exist, instead serves the text
210210"403 Forbidden", as per :rfc:`2616` (the HTTP 1.1 Specification).
211211
212+ ``django.views.defaults.permission_denied`` is triggered by a
213+ :exc:`~django.core.exceptions.PermissionDenied` exception. To deny access in a
214+ view you can use code like this::
215+
216+ from django.core.exceptions import PermissionDenied
217+
218+ def edit(request, pk):
219+ if not request.user.is_staff:
220+ raise PermissionDenied
221+ # ...
222+
212223It is possible to override ``django.views.defaults.permission_denied`` in the
213224same way you can for the 404 and 500 views by specifying a ``handler403`` in
214225your URLconf::
You can’t perform that action at this time.
0 commit comments