Opened 16 years ago
Closed 16 years ago
#8463 closed (invalid)
force_insert doesn't work with inherited models
Reported by: | Nicolas Dietrich | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | dev |
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
The following testcase describes the problem best:
Model:
from django.db import models class Parent(models.Model): something = models.SlugField() class Daughter(Parent): pass
Interactive session:
In [1]: from appname.models import Daughter In [2]: d = Daughter(something='algo') In [3]: d.save() In [4]: d.something='otra' In [5]: d.save(force_insert=True)
results in
IntegrityError: duplicate key value violates unique constraint "appname_daughter_pkey"
Change History (1)
comment:1 by , 16 years ago
milestone: | 1.0 |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
That's not a bug, it's exactly the right behaviour. You created
d
and then you try to save it with updated data (the primary key will still be the same), but say you want to force an insert. The database says the record already exists with that primary key value.