class Article(models.Model):
body = models.CharField(max_length=200)
class Admin:
pass
class Attachment(models.Model):
article = models.ForeignKey(Article, num_in_admin=1, num_extra_on_change=1, edit_inline=models.TABULAR)
file = models.FileField(upload_to='uploads/attachments/%Y/%m/%d')
keep = models.BooleanField(core=True, default=True, editable=False)
remove = models.BooleanField(default=False)
name = models.CharField(max_length=30)
Django admin breaks when attempting to create a new Article w/o any attachments. The problem is that after the introduction of MultiPartParser? in 7814, request.POST contains an entry
u'attachment.0.file_file': [u'']
whereas that entry would be missing in prior revisions. This eventually leads to an entry of:
u'file_file': [u'']
instead of
u'file_file': []
in the new_data dict which is passed as the parameter to FileField?.save_file, so this method eventually breaks. The fix is simple and I'm attaching a patch for it. The only thing is that I'm not sure if it would perhaps be better to handle this somewhere else?