Django: Orphan parent instances when saving of child fails -
i have photo class inherits content model this:
class content(models.model): added = models.datetimefield(auto_now_add=true) modified = models.datetimefield(auto_now=true) class photo(content): file = models.imagefield(upload_to='photos/') def __unicode__(self): return self.caption , self.caption or '' as can seen, content not abstract. modelform, uploading photos. but, if saving of photo fails reason, orphan content instance left. guess instance parent model created before photo instance saved if photo fails, parent not cleaned-up.
is bug on django side? how can prevented?
same always. use transactions.
Comments
Post a Comment