mirror of
https://github.com/django/django.git
synced 2025-08-04 10:59:45 +00:00
Fixed #12152. DoesNotExist and MultipleObjectsReturned now subclass their parent model's exceptions. Thanks, mattmcc and Alex Gaynor.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12567 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
de1ff3e51d
commit
1089bda546
3 changed files with 73 additions and 8 deletions
|
@ -206,6 +206,26 @@ False
|
|||
>>> MyPersonProxy.objects.all()
|
||||
[<MyPersonProxy: Bazza del Frob>, <MyPersonProxy: Foo McBar>, <MyPersonProxy: homer>]
|
||||
|
||||
# Proxy models are included in the ancestors for a model's DoesNotExist and MultipleObjectsReturned
|
||||
>>> try:
|
||||
... MyPersonProxy.objects.get(name='Zathras')
|
||||
... except Person.DoesNotExist:
|
||||
... pass
|
||||
>>> try:
|
||||
... MyPersonProxy.objects.get(id__lt=10)
|
||||
... except Person.MultipleObjectsReturned:
|
||||
... pass
|
||||
>>> try:
|
||||
... StatusPerson.objects.get(name='Zathras')
|
||||
... except Person.DoesNotExist:
|
||||
... pass
|
||||
>>> sp1 = StatusPerson.objects.create(name='Bazza Jr.')
|
||||
>>> sp2 = StatusPerson.objects.create(name='Foo Jr.')
|
||||
>>> try:
|
||||
... StatusPerson.objects.get(id__lt=10)
|
||||
... except Person.MultipleObjectsReturned:
|
||||
... pass
|
||||
|
||||
# And now for some things that shouldn't work...
|
||||
#
|
||||
# All base classes must be non-abstract
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue