Code

Ticket #3632: forms.py.2.diff

File forms.py.2.diff, 792 bytes (added by empty <mtrier@…>, 6 years ago)

Updated because SortedDictFromList was removed

Line 
1Index: newforms/forms.py
2===================================================================
3--- newforms/forms.py   (revision 6783)
4+++ newforms/forms.py   (working copy)
5@@ -38,7 +38,14 @@
6             if hasattr(base, 'base_fields'):
7                 fields = base.base_fields.items() + fields
8 
9-        attrs['base_fields'] = SortedDict(fields)
10+        # preserve initial values
11+        base_fields = SortedDict(fields)
12+        if attrs.get('base_fields'):
13+            base_fields = base_fields.copy()
14+            for k, v in attrs.get('base_fields').items():
15+                if k in base_fields:
16+                    base_fields[k].initial = v.initial
17+        attrs['base_fields'] = base_fields
18         return type.__new__(cls, name, bases, attrs)
19 
20 class BaseForm(StrAndUnicode):