From 8c8625bde346d619befbdbb8a550368aa9b54b4d Mon Sep 17 00:00:00 2001 From: Karen Tracey Date: Tue, 19 May 2009 23:13:33 +0000 Subject: 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 --- django/forms/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'django/forms/models.py') 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]) -- cgit v1.3