7 | | |
8 | | When BaseForm:__init__() runs, it does a deepcopy of self.base_fields. When copying the fields, we call the Widget::__deepcopy__() method. However, this method copies only the attributes and does not copy the !ModelChoiceIterator that a select widget points to. I think that a copy should be made of this !ModelChoiceIterator, and furthermore, I think that after making the copy, the newly copied !ModelChoiceIterator's 'field' attribute needs to be updated so that it points to the copied field whose deepcopy caused it to be copied. |
| 8 | }}} |
| 9 | When `BaseForm:__init__()` runs, it does a deepcopy of self.base_fields. When copying the fields, we call the `Widget::__deepcopy__()` method. However, this method copies only the attributes and does not copy the !ModelChoiceIterator that a select widget points to. I think that a copy should be made of this !ModelChoiceIterator, and furthermore, I think that after making the copy, the newly copied !ModelChoiceIterator's 'field' attribute needs to be updated so that it points to the copied field whose deepcopy caused it to be copied. |
29 | | * Created a __deepcopy__() method for the Select widget, which does the same thin that Widget::__deepcopy__() does, but also calls copy on the self.choices field |
30 | | * Created a small loop that follows the deepcopy in BaseForm:__init__(), which runs through all fields that were copied, and if the field contains a'widget' attribute and that widget attribute contains a 'choices' attribute and that 'choices' attribute contains a 'field' attribute, then it sets that 'field' attribute point to the newly copied field. This is the part that I think is pretty ugly. |
| 30 | * Created a `__deepcopy__()` method for the Select widget, which does the same thin that `Widget::__deepcopy__()` does, but also calls copy on the self.choices field |
| 31 | * Created a small loop that follows the deepcopy in `BaseForm:__init__()`, which runs through all fields that were copied, and if the field contains a'widget' attribute and that widget attribute contains a 'choices' attribute and that 'choices' attribute contains a 'field' attribute, then it sets that 'field' attribute point to the newly copied field. This is the part that I think is pretty ugly. |