diff --git a/django/newforms/widgets.py b/django/newforms/widgets.py index 0e7752499e..355695efd2 100644 --- a/django/newforms/widgets.py +++ b/django/newforms/widgets.py @@ -7,7 +7,9 @@ try: except NameError: from sets import Set as set # Python 2.3 fallback +import copy from itertools import chain + from django.utils.datastructures import MultiValueDict from django.utils.html import escape from django.utils.translation import ugettext @@ -32,6 +34,12 @@ class Widget(object): else: self.attrs = {} + def __deepcopy__(self, memo): + obj = copy.copy(self) + obj.attrs = self.attrs.copy() + memo[id(self)] = obj + return obj + def render(self, name, value, attrs=None): """ Returns this Widget rendered as HTML, as a Unicode string.