Login

middleware to capture doesnot exists exception

Author:
vbachu
Posted:
July 12, 2013
Language:
Python
Version:
Not specified
Tags:
middleware django exceptions objectdoesnotexist doesnotexists
Score:
0 (after 0 ratings)

middleware to capture exceptions doesnotexists,objectdoesnotexists

 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 4 years, 10 months ago
  2. CrashKit Middleware by wiz 5 years, 11 months ago
  3. Log Django exceptions to Apache error log in mod_wsgi by simon 5 years, 6 months ago
  4. Message exception by marinho 6 years, 5 months ago
  5. Extensible exception handling middleware by kcarnold 7 years ago

Comments

Please login first before commenting.