[Answer]-"No data received" with custom handler403 in django

1👍

TemplateView returns a TemplateResponse instance with lazy content rendering by default, and is not suitable as is for handler403.

To force this view to render it’s content, make sure .render() is called before returning the response:

class PermissionDeniedView(TemplateView):
    template_name = '403.html'

    def dispatch(self, request, *args, **kwargs):
        response = super(PermissionDeniedView, self).dispatch(request, *args, **kwargs)
        response.render()
        return response
👤Udi

Leave a comment