Jason Xu
Jason Xu

Reputation: 2963

Permission denied with error info?

in Django is there an official way to return PermissionDenied exception with some text of error info as response body to browser?

Upvotes: 1

Views: 883

Answers (1)

Yes, the docs have official viewpoints.

In the same vein as the 404 and 500 views, Django has a view to handle 403 Forbidden errors. If a view results in a 403 exception then Django will, by default, call the view django.views.defaults.permission_denied.

This view loads and renders the template 403.html in your root template directory, or if this file does not exist, instead serves the text "403 Forbidden", as per RFC 2616 (the HTTP 1.1 Specification).

Upvotes: 3

Related Questions