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

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -