Code

Ticket #3727: newforms_save_instance.diff

File newforms_save_instance.diff, 642 bytes (added by Matias Hermanrud Fjeld <mhf@…>, 7 years ago)

diff against r4741

Line 
1Index: django/newforms/models.py
2===================================================================
3--- django/newforms/models.py   (revision 4607)
4+++ django/newforms/models.py   (working copy)
5@@ -36,7 +36,8 @@
6         raise ValueError("The %s could not be changed because the data didn't validate." % opts.object_name)
7     clean_data = form.clean_data
8     for f in opts.fields:
9-        if not f.editable or isinstance(f, models.AutoField):
10+        if not f.editable or isinstance(f, models.AutoField) \
11+           or f.name not in clean_data:
12             continue
13         setattr(instance, f.name, clean_data[f.name])
14     if commit: