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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -