mirror of
https://github.com/django/django.git
synced 2025-07-19 09:09:13 +00:00
[1.9.x] Fixed #25461 -- Corrected meta API code examples to account for MTI.
In the case of multiple-table inheritance models, get_all_related_objects() and get_all_related_objects_with_model() don't return the auto-created OneToOneField, but the new examples didn't account for this. Backport of 8be84e2ac42b2556fd6fa07794b3708b143ef341 from master
This commit is contained in:
parent
3cd3a1af6d
commit
ca7b926c85
@ -238,7 +238,8 @@ can be made to convert your code to the new API:
|
|||||||
|
|
||||||
[
|
[
|
||||||
f for f in MyModel._meta.get_fields()
|
f for f in MyModel._meta.get_fields()
|
||||||
if (f.one_to_many or f.one_to_one) and f.auto_created
|
if (f.one_to_many or f.one_to_one)
|
||||||
|
and f.auto_created and not f.concrete
|
||||||
]
|
]
|
||||||
|
|
||||||
* ``MyModel._meta.get_all_related_objects_with_model()`` becomes::
|
* ``MyModel._meta.get_all_related_objects_with_model()`` becomes::
|
||||||
@ -246,7 +247,8 @@ can be made to convert your code to the new API:
|
|||||||
[
|
[
|
||||||
(f, f.model if f.model != MyModel else None)
|
(f, f.model if f.model != MyModel else None)
|
||||||
for f in MyModel._meta.get_fields()
|
for f in MyModel._meta.get_fields()
|
||||||
if (f.one_to_many or f.one_to_one) and f.auto_created
|
if (f.one_to_many or f.one_to_one)
|
||||||
|
and f.auto_created and not f.concrete
|
||||||
]
|
]
|
||||||
|
|
||||||
* ``MyModel._meta.get_all_related_many_to_many_objects()`` becomes::
|
* ``MyModel._meta.get_all_related_many_to_many_objects()`` becomes::
|
||||||
|
Loading…
x
Reference in New Issue
Block a user