Question about @errorify
qcoumes opened this issue · 2 comments
qcoumes commented
I'm not sure to understand what @errorify
does, is it an alternative to HTTPExceptions.BASE_EXCEPTION.register_default_view(view)
?
Are
@errorify(HTTPExceptions.FORBIDDEN)
def default_view_403(_):
return HttpResponse("I'm the 403 default view")
and
HTTPExceptions.FORBIDDEN.register_default_view(default_view_403)
equivalent ?
isik-kaplan commented
They are not, but yes you are right, the example I gave and the name of the function doesn't exactly make sense, sorry. It actually just changes the status of a view's response, and locks the view to only that response status code.
I'll try to give a better example than what's in the readme.
For instance you want to close down the /downloads/
section
@errorify(HTTPExceptions.SERVICE_UNAVAILABLE)
class Downloads(TemplateView):
# template = 'downloads.html'
template = 'under_maintenance.html'
I hope it makes sense now. I'm really bad at giving examples.
qcoumes commented
Thanks for the explanation ! That last example wast perfect.