Ticket #11183: 11183

File 11183, 1.2 KB (added by margieroginski, 6 years ago)
Line 
1
2Index: forms.py
3===================================================================
4--- forms.py    (revision 10821)
5+++ forms.py    (working copy)
6@@ -88,7 +88,13 @@
7         # alter self.fields, we create self.fields here by copying base_fields.
8         # Instances should always modify self.fields; they should not modify
9         # self.base_fields.
10+       
11         self.fields = deepcopy(self.base_fields)
12+        for fieldName, field in self.fields.items():
13+            try:
14+                field.widget.choices.field = field
15+            except:
16+                pass
17 
18     def __unicode__(self):
19         return self.as_table()
20Index: widgets.py
21===================================================================
22--- widgets.py  (revision 10821)
23+++ widgets.py  (working copy)
24@@ -396,6 +396,13 @@
25         # more than once.
26         self.choices = list(choices)
27 
28+    def __deepcopy__(self, memo):
29+        obj = copy.copy(self)
30+        obj.attrs = self.attrs.copy()
31+        obj.choices = copy.copy(self.choices)
32+        memo[id(self)] = obj
33+        return obj
34+
35     def render(self, name, value, attrs=None, choices=()):
36         if value is None: value = ''
37         final_attrs = self.build_attrs(attrs, name=name)
Back to Top