Code

Ticket #3258: savesubset.diff

File savesubset.diff, 540 bytes (added by Andrew Durdin <adurdin@…>, 8 years ago)

patch

Line 
1Index: django/newforms/models.py
2===================================================================
3--- django/newforms/models.py   (revision 4300)
4+++ django/newforms/models.py   (working copy)
5@@ -36,7 +36,8 @@
6     for f in opts.fields + opts.many_to_many:
7         if isinstance(f, models.AutoField):
8             continue
9-        setattr(instance, f.attname, clean_data[f.name])
10+        if f.name in clean_data:
11+            setattr(instance, f.attname, clean_data[f.name])
12     if commit:
13         instance.save()
14     return instance