From chat with Monique: the problem is in the (non-posted) Photo.save()
method that makes two calls to super().save()
, passing the same args in both cases, so the first call correctly creates the Photo
instance and the second tries to insert it again, which obviously fails.
Solution (for anyone having the same problem): dont blindly pass *args
and **kwargs
to Model.save()
when your overload it and end up calling it a second time.
class Foo(models.Model):
def save(self, force_insert=False, force_update=False, **kwargs):
super(Foo, self).save(force_insert, force_update, **kargs)
if somethings_needs_to_be_done:
do_something_here()
super(Foo, self).save(force_insert=False, force_update=True, **kwargs)