Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#805 closed defect (invalid)

OneToOneField conflicts with ForeignKey

Reported by: kevinastone@… Owned by: adrian
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: UI/UX:

Description (last modified by adrian)

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 Changed 9 years ago by adrian

  • Description modified (diff)

(Fixed formatting in description.)

comment:2 Changed 8 years ago by mtredinnick

  • Resolution set to invalid
  • Status changed from new to closed

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

comment:3 Changed 8 years ago by ubernostrum

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