From 8ee6a3f1a855bf983639a14fc2393baa8ead741f Mon Sep 17 00:00:00 2001 From: Eric Carrillo Date: Wed, 8 Jul 2015 19:03:11 -0500 Subject: [PATCH] Fixed #25085 -- Overrode Select widget's __deepcopy__() --- django/forms/widgets.py | 7 +++++++ tests/forms_tests/tests/test_widgets.py | 15 +++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 896984dc08..c744d090ad 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -521,6 +521,13 @@ class Select(Widget): # more than once. self.choices = list(choices) + def __deepcopy__(self, memo): + obj = copy.copy(self) + obj.attrs = self.attrs.copy() + obj.choices = copy.copy(self.choices) + memo[id(self)] = obj + return obj + def render(self, name, value, attrs=None, choices=()): if value is None: value = '' diff --git a/tests/forms_tests/tests/test_widgets.py b/tests/forms_tests/tests/test_widgets.py index 40ff750f60..2f1b6e48f7 100644 --- a/tests/forms_tests/tests/test_widgets.py +++ b/tests/forms_tests/tests/test_widgets.py @@ -1997,3 +1997,18 @@ class SelectDateWidgetTests(SimpleTestCase): # label tag is correctly associated with first rendered dropdown a = GetDate({'mydate_month': '1', 'mydate_day': '1', 'mydate_year': '2010'}) self.assertIn('