Why can't I save my model with a generic relation twice in Django? -
i got model trackeditem generic relation linking model supposed track.
if that:
t = trackeditem(content_object=mymodel) t.save() t.save()
i :
integrityerror: (1062, "duplicate entry '1' key 'primary'")
indeed, first save has created entry "1" pk. second save should not insert, should update.
how suppose update model can't save twice?
with ordinary model can save as want.
edit : may not related @ generic relations.
i'm having overrided save, , call super in it, way :
super(trackeditem, self).save(self, *args, **kwargs)
if way, works:
model.model.save(self, *args, **kwargs)
your problem because of wrong use of 'super'. should this:
super(trackeditem, self).save(*args, **kwargs)
Comments
Post a Comment