#25461: Model _meta API Migration Guide
-------------------------------+--------------------
     Reporter:  ad-65          |      Owner:  nobody
         Type:  Bug            |     Status:  new
    Component:  Documentation  |    Version:  1.8
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 The _meta API migration guide for Django 1.8 shows a replacement for
 _meta.get_all_related_objects() that isn't quite right when used on a
 multi-table inheritance child model.

 {{{#!python

 class Party():
     is_active = models.BooleanField(default=True)

 class Contact(Party):
     first_name = models.CharField(max_length=128)
     last_name = models.CharField(max_length=128)
 }}}

 {{{#!python

 [f for f in Contact._meta.get_all_related_objects()]
 ...
 []

 [f for f in Contact._meta.get_fields() if (f.one_to_many or f.one_to_one)
 and f.auto_created]
 ...
 [<django.db.models.fields.related.OneToOneField: party_ptr>]

 }}}

 The _meta.get_all_related_objects() method would return nothing assuming
 no other external relations but the replacement method would return the
 automatically created OneToOneField pointing to the parent. Maybe changing
 the docs to use is_concrete would work, unless this causes other problems?

 {{{#!python

 [f for f in Contact._meta.get_all_related_objects()]
 ...
 []

 [f for f in Contact._meta.get_fields() if (f.one_to_many or f.one_to_one)
 and f.auto_created and not f.concrete]
 ...
 []

 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25461>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/048.4a7bbe14bf2ae5fe60d06de996221ce9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to