Search code examples
pyramidhttp-status-code-403

using custom page for 403 Forbidden in pyramid


I have seen the documentation but i am not able to make it working.If anyone could explain me more clearly how to create a custom 403 page in pyramid,it would be great

Thanks


Solution

  • You can add a renderer to your @forbidden_view_config() decorator: @forbidden_view_config(renderer='myforbiddentemplate.mako')

    Or, you could probably also do some sort of custom views, too:

    from pyramid.httpexceptions import ( HTTPFound, HTTPNotFound, HTTPForbidden, HTTPBadRequest, HTTPInternalServerError )

    @view_config(context=HTTPNotFound, renderer='HTTPNotFoundPage.mako') def my_view(request):