Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #9882 -- Added `alters_data = True` to `BaseModelForm.save` met…

…hod, thanks dc.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9678 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit f0d44e44bd4161d279ea9b6a9c99af79cf17b913 1 parent 7bf9626
Gary Wilson Jr. authored

Showing 1 changed file with 11 additions and 9 deletions. Show diff stats Hide diff stats

  1. 20  django/forms/models.py
20  django/forms/models.py
@@ -56,10 +56,10 @@ def save_instance(form, instance, fields=None, fail_message='saved',
56 56
             file_field_list.append(f)
57 57
         else:
58 58
             f.save_form_data(instance, cleaned_data[f.name])
59  
-            
  59
+
60 60
     for f in file_field_list:
61 61
         f.save_form_data(instance, cleaned_data[f.name])
62  
-        
  62
+
63 63
     # Wrap up the saving of m2m data as a function.
64 64
     def save_m2m():
65 65
         opts = instance._meta
@@ -226,11 +226,11 @@ def clean(self):
226 226
     def validate_unique(self):
227 227
         from django.db.models.fields import FieldDoesNotExist
228 228
 
229  
-        # Gather a list of checks to perform. We only perform unique checks 
230  
-        # for fields present and not None in cleaned_data.  Since this is a 
231  
-        # ModelForm, some fields may have been excluded; we can't perform a unique 
  229
+        # Gather a list of checks to perform. We only perform unique checks
  230
+        # for fields present and not None in cleaned_data.  Since this is a
  231
+        # ModelForm, some fields may have been excluded; we can't perform a unique
232 232
         # check on a form that is missing fields involved in that check.  It also does
233  
-        # not make sense to check data that didn't validate, and since NULL does not 
  233
+        # not make sense to check data that didn't validate, and since NULL does not
234 234
         # equal NULL in SQL we should not do any unique checking for NULL values.
235 235
         unique_checks = []
236 236
         for check in self.instance._meta.unique_together[:]:
@@ -318,6 +318,8 @@ def save(self, commit=True):
318 318
             fail_message = 'changed'
319 319
         return save_instance(self, self.instance, self._meta.fields, fail_message, commit)
320 320
 
  321
+    save.alters_data = True
  322
+
321 323
 class ModelForm(BaseModelForm):
322 324
     __metaclass__ = ModelFormMetaclass
323 325
 
@@ -480,7 +482,7 @@ def _construct_form(self, i, **kwargs):
480 482
             # creating new instances
481 483
             form.data[form.add_prefix(self._pk_field.name)] = None
482 484
         return form
483  
-    
  485
+
484 486
     def save_new(self, form, commit=True):
485 487
         fk_attname = self.fk.get_attname()
486 488
         kwargs = {fk_attname: self.instance.pk}
@@ -585,7 +587,7 @@ class InlineForeignKeyField(Field):
585 587
     default_error_messages = {
586 588
         'invalid_choice': _(u'The inline foreign key did not match the parent instance primary key.'),
587 589
     }
588  
-    
  590
+
589 591
     def __init__(self, parent_instance, *args, **kwargs):
590 592
         self.parent_instance = parent_instance
591 593
         self.pk_field = kwargs.pop("pk_field", False)
@@ -594,7 +596,7 @@ def __init__(self, parent_instance, *args, **kwargs):
594 596
         kwargs["required"] = False
595 597
         kwargs["widget"] = InlineForeignKeyHiddenInput
596 598
         super(InlineForeignKeyField, self).__init__(*args, **kwargs)
597  
-    
  599
+
598 600
     def clean(self, value):
599 601
         if value in EMPTY_VALUES:
600 602
             if self.pk_field:

0 notes on commit f0d44e4

Please sign in to comment.
Something went wrong with that request. Please try again.