Opened 7 years ago

Closed 7 years ago

#16944 closed Bug (duplicate)

multiple inheritance issue

Reported by: pegler@… Owned by: nobody
Component: Database layer (models, ORM) Version: 1.3
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


Django's support for multiple inheritance from several non-abstract models seems to almost be working. When both parent models have the same name for their PK, saving will update a related row instead of insert a new one.


Model: Pet - pk: id
Model: Mammal - pk: id
Model: Cat - inherits from Pet and Mammal, pk on the 2 foreign keys will first insert a Pet row, since id isn't yet set. It will then set to the new id values from Pet. It will then try to save Mammal, but since id has been set from Pet, it will try to update/insert a Mammal row (instead of always inserting).

The code at fault is here:

I am not sure of the best solution for this, but perhaps not setting attributes that are also primary keys of other parent models.

Change History (1)

comment:1 Changed 7 years ago by anonymous

Resolution: duplicate
Status: newclosed

I think this is #12002.

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