diff --git a/django/newforms/forms.py b/django/newforms/forms.py index 44e5bf3d070..58d23e49e07 100644 --- a/django/newforms/forms.py +++ b/django/newforms/forms.py @@ -234,9 +234,7 @@ class BoundField(StrAndUnicode): def _data(self): "Returns the data for this BoundField, or None if it wasn't given." - if self.field.widget.requires_data_list and isinstance(self.form.data, MultiValueDict): - return self.form.data.getlist(self.html_name) - return self.form.data.get(self.html_name, None) + return self.field.widget.value_from_datadict(self.form.data, self.html_name) data = property(_data) def label_tag(self, contents=None): diff --git a/django/newforms/widgets.py b/django/newforms/widgets.py index ba11f350085..0dd0692e29c 100644 --- a/django/newforms/widgets.py +++ b/django/newforms/widgets.py @@ -23,13 +23,18 @@ except NameError: flatatt = lambda attrs: u''.join([u' %s="%s"' % (k, escape(v)) for k, v in attrs.items()]) class Widget(object): - requires_data_list = False # Determines whether render()'s 'value' argument should be a list. is_hidden = False # Determines whether this corresponds to an . def __init__(self, attrs=None): self.attrs = attrs or {} - def render(self, name, value): + def render(self, name, value, attrs=None): + """ + Returns this Widget rendered as HTML, as a Unicode string. + + The 'value' given is not guaranteed to be valid input, so subclass + implementations should program defensively. + """ raise NotImplementedError def build_attrs(self, extra_attrs=None, **kwargs): @@ -130,7 +135,6 @@ class Select(Widget): return u'\n'.join(output) class SelectMultiple(Widget): - requires_data_list = True def __init__(self, attrs=None, choices=()): # choices can be any iterable self.attrs = attrs or {}