2👍
✅
Why not have your 500.html
template simply display the error message you want?
Otherwise, you could create a middleware to catch this error:
from django.shortcuts import render
class CatchOperationalError(object):
def process_exception(self, request, exception):
if type(exception).__name__ == 'OperationalError': # replace with proper isinstance
return render(request, 'wordpress_down.html')
https://docs.djangoproject.com/en/dev/topics/http/middleware/#process_exception
Another option would be to wrap each individual view in a try/except.
Source:stackexchange.com