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. Automatically setup raw_id_fields ForeignKey & OneToOneField by agusmakmun 5 months, 1 week ago
  2. Crispy Form by sourabhsinha396 6 months ago
  3. ReadOnlySelect by mkoistinen 6 months, 2 weeks ago
  4. Verify events sent to your webhook endpoints by santos22 7 months, 2 weeks ago
  5. Django Language Middleware by agusmakmun 7 months, 3 weeks ago

Comments

Please login first before commenting.