Ticket #3635: models.diff
File models.diff, 1.0 KB (added by , 18 years ago) |
---|
-
newforms/models.py
36 36 raise ValueError("The %s could not be changed because the data didn't validate." % opts.object_name) 37 37 clean_data = form.clean_data 38 38 for f in opts.fields: 39 if not f.editable or isinstance(f, models.AutoField) :39 if not f.editable or isinstance(f, models.AutoField) or not f.name in clean_data: 40 40 continue 41 41 setattr(instance, f.name, clean_data[f.name]) 42 42 if commit: 43 43 instance.save() 44 44 for f in opts.many_to_many: 45 setattr(instance, f.attname, clean_data[f.name]) 45 if f.name in clean_data: 46 setattr(instance, f.attname, clean_data[f.name]) 46 47 # GOTCHA: If many-to-many data is given and commit=False, the many-to-many 47 48 # data will be lost. This happens because a many-to-many options cannot be 48 49 # set on an object until after it's saved. Maybe we should raise an