Django Model Save and "Duplicate entry for key PRIMARY" -
i have django model, 2 foreignkey filed 1 model:
class mymodel(models.model): user = models.foreignkey(user) boss = models.foreignkey(user, blank=true, null=true, related_name = 'the_boss') def save(self, *args, **kwargs) if self.pk: #do staff super(mymodel, self).save(*args, **kwargs)
the boss
field, add together in model update. when model updates (django admin) have
duplicate entry key primary
super(mymodel, self).save(self, *args, **kwargs)
error. help issue appreciated.
try adding related_name
user foreignkey well
django django-models
No comments:
Post a Comment