diff options
| author | Karen Tracey <kmtracey@gmail.com> | 2009-05-19 23:13:33 +0000 |
|---|---|---|
| committer | Karen Tracey <kmtracey@gmail.com> | 2009-05-19 23:13:33 +0000 |
| commit | 8c8625bde346d619befbdbb8a550368aa9b54b4d (patch) | |
| tree | 37e4a31b900b9e7fdb6a2d32a455d8832fb8887c /django/forms/models.py | |
| parent | 2e24596001bce6e827e31510241834ccff76979f (diff) | |
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
Diffstat (limited to 'django/forms/models.py')
| -rw-r--r-- | django/forms/models.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/django/forms/models.py b/django/forms/models.py index aab870b6a0..a0b217860d 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -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]) |
