[Django]-How does one create a custom 403 page in Django?

6👍

The handler403 is new in the development version. If you’re using an older version (<= 1.3) this option is not yet implemented.

There are some ways of accomplishing that in older versions, as described here. It involves a new middleware, a custom exception and the HttpResponseForbidden. Don’t know how well it would integrate with the rest of your project, though…

4👍

Google Chrome will replace it with their generic one if the returned page is less than 512 bytes in size. They do the same with 404 responses as well.

For what it’s worth Internet Explorer does the same thing.

If you make your response greater than 512bytes then all shall be well.

Leave a comment