Fixed #11149 -- Don't call save_form_data on file-type fields multiple times when saving a model form.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10826 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Karen Tracey 2009-05-19 23:13:33 +00:00
parent 2e24596001
commit 8c8625bde3
3 changed files with 27 additions and 5 deletions

View file

@ -28,3 +28,12 @@ class Article(models.Model):
def __unicode__(self):
return self.headline
class CustomFileField(models.FileField):
def save_form_data(self, instance, data):
been_here = getattr(self, 'been_saved', False)
assert not been_here, "save_form_data called more than once"
setattr(self, 'been_saved', True)
class CustomFF(models.Model):
f = CustomFileField(upload_to='unused', blank=True)