#805 closed defect (invalid)
OneToOneField conflicts with ForeignKey
| Reported by: | 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 )
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 , 20 years ago
| Description: | modified (diff) | 
|---|
comment:2 by , 19 years ago
| Resolution: | → invalid | 
|---|---|
| Status: | new → closed | 
This refers to an API we no longer have. Closing.
comment:3 by , 19 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.
    
(Fixed formatting in description.)