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

Popular posts from this blog

java - How to pass parameters between Request-Scoped Controllers? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -

string - what is the difference between "some" == "some\0" and strcmp("some","some\0") in c++? -