Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#805 closed defect (invalid)

OneToOneField conflicts with ForeignKey

Reported by: kevinastone@… Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version:
Severity: normal 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 (last modified by Adrian Holovaty)

I have a model class that has both a OneToOneField and a ForeignKey to the same other class. Eg.

class Base(meta.Model):
    name = CharField()

class Extension(meta.Model):
    base = meta.OneToOneField(Base)
    parent = meta.ForeignKey(Base)

When using Base instance, when I try to call Base.get_extension() it uses the parent foreign key reference instead of the base OneToOne reference.

Change History (3)

comment:1 by Adrian Holovaty, 18 years ago

Description: modified (diff)

(Fixed formatting in description.)

comment:2 by Malcolm Tredinnick, 18 years ago

Resolution: invalid
Status: newclosed

This refers to an API we no longer have. Closing.

comment:3 by James Bennett, 18 years ago

Also, model validation should catch these sorts of problems with the new setup, and error out when two relations try to have the same descriptor attached, in which case it tells you to set related_name on one of them.

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