I am running multiple databases and I need to handle this exception. How can I do it either in the view or a more general approach ? I am using PostgreSQL. It's a bit ugly to wrap my whole code like below.
import psycopg2
def Main(request):
try:
myqs = customers.objects.all()
except psycopg2.OperationalError as e:
print('operational error, handle this')
return render(request, 'core/main/main.html', {'qs': myqs})
