1
0
mirror of https://github.com/django/django.git synced 2025-10-25 06:36:07 +00:00

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

@@ -50,14 +50,14 @@ def save_instance(form, instance, fields=None, fail_message='saved',
continue
if exclude and f.name in exclude:
continue
# OneToOneField doesn't allow assignment of None. Guard against that
# instead of allowing it and throwing an error.
if isinstance(f, models.OneToOneField) and cleaned_data[f.name] is None:
continue
# Defer saving file-type fields until after the other fields, so a
# callable upload_to can use the values from other fields.
if isinstance(f, models.FileField):
file_field_list.append(f)
# OneToOneField doesn't allow assignment of None. Guard against that
# instead of allowing it and throwing an error.
if isinstance(f, models.OneToOneField) and cleaned_data[f.name] is None:
pass
else:
f.save_form_data(instance, cleaned_data[f.name])