middleware to capture doesnot exists exception

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
class CheckDoesNotExistsMiddleware(object):

    def process_exception(self, request, exception):
        if isinstance(exception, ObjectDoesNotExist):
            raise Http404

in settings.py 
MIDDLEWARE_CLASSES = (
    ...........
    ...........
    'gcrmserver.apps.core.middleware.CheckDoesNotExistsMiddleware',

)

More like this

  1. Capture Stack Trace Decorator by LorenDavie 3 years, 11 months ago
  2. CrashKit Middleware by wiz 4 years, 11 months ago
  3. Log Django exceptions to Apache error log in mod_wsgi by simon 4 years, 7 months ago
  4. Message exception by marinho 5 years, 6 months ago
  5. Extensible exception handling middleware by kcarnold 6 years, 1 month ago

Comments

(Forgotten your password?)