Opened 14 years ago

Last modified 14 years ago

#15225 closed

Using concrete model inheritance with OneToOneField(parent_link=True) seems to be ignored — at Initial Version

Reported by: Jeremy Dunck Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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.

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top