#15225: Using concrete model inheritance with OneToOneField(parent_link=True)
seems
to be ignored
--------------------------------------------------------+-------------------
Reporter: jdunck | Owner: nobody
Status: new | Milestone:
Component: Database layer (models, ORM) | Version: 1.2
Resolution: | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 |
--------------------------------------------------------+-------------------
Description changed by jdunck:
Old description:
> This seems to be because local_fields is always blank in these lines from
> django.db.models.base.ModelBase.__new__
>
> # Do the appropriate setup for any model parents.
> o2o_map = dict([(f.rel.to, f) for f in
> new_class._meta.local_fields
> if isinstance(f, OneToOneField)])
>
> Which causes this elif branch to be taken:
>
> if base in o2o_map:
> field = o2o_map[base]
> elif not is_proxy:
> attr_name = '%s_ptr' % base._meta.module_name
> field = OneToOneField(base, name=attr_name,
> auto_created=True, parent_link=True)
> new_class.add_to_class(attr_name, field)
>
> This misses the point of parent_link.
>
> I'll try to make a simple test case (for some value of "simple"), but can
> anyone verify? Kooky edge case, I know.
New description:
This seems to be because local_fields is always blank in these lines from
django.db.models.base.ModelBase.__new__
{{{
# Do the appropriate setup for any model parents.
o2o_map = dict([(f.rel.to, f) for f in
new_class._meta.local_fields
if isinstance(f, OneToOneField)])
}}}
Which causes this elif branch to be taken:
{{{
if base in o2o_map:
field = o2o_map[base]
elif not is_proxy:
attr_name = '%s_ptr' % base._meta.module_name
field = OneToOneField(base, name=attr_name,
auto_created=True, parent_link=True)
new_class.add_to_class(attr_name, field)
}}}
This misses the point of parent_link.
I'll try to make a simple test case (for some value of "simple"), but can
anyone verify? Kooky edge case, I know.
--
--
Ticket URL: <http://code.djangoproject.com/ticket/15225#comment:1>
Django <http://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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.