Is there a way to catch 500 errors in django python? -


i catch 500 exception , return http 4xx exception instead. using "except exception" catch exceptions not desired. wondering there way catch 500 errors

try:    <code> except <exception class>:    return http 404 reponse 

i searched lot couldn't figure out how same. in advance

i'm not sure returning 404 instead of 500 idea, can acheive defining custom error handler 500 errors.

in urls.py:

handler500 = 'mysite.views.my_custom_error_view' 

in views.py:

from django.http import httpresponse  def my_custom_error_view(request):     """     return 404 response instead of 500.     """     return httpresponse("error message", status_code=404) 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -