python - Which file is used in import statement for 'MultipleObjectsReturne' exception -
python - Which file is used in import statement for 'MultipleObjectsReturne' exception -
i using code
except multipleobjectsreturned: homecoming httpresponse('some error')
but error
global name 'multipleobjectsreturned' not defined
you can either:
from django.core.exceptions import multipleobjectsreturned except multipleobjectsreturned e: homecoming httpresponse(e)
or:
except yourmodel.multipleobjectsreturned e: homecoming httpresponse(e)
https://docs.djangoproject.com/en/1.3/ref/exceptions/#django.core.exceptions.multipleobjectsreturned
a base of operations version of exception provided in django.core.exceptions
; each model class contains subclassed version can used identify specific object type has returned multiple objects.
python exception-handling
Comments
Post a Comment