diff --git a/floppyforms/widgets.py b/floppyforms/widgets.py index c890a6e..5b8cddc 100644 --- a/floppyforms/widgets.py +++ b/floppyforms/widgets.py @@ -45,6 +45,23 @@ class Widget(forms.Widget): def is_hidden(self): return self.input_type == 'hidden' if hasattr(self, 'input_type') else False + 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('subclasses of Widget must provide a render() method') + + def build_attrs(self, extra_attrs=None, **kwargs): + """ + Backported from Django 1.10 + Helper function for building an attribute dictionary. + """ + attrs = dict(self.attrs, **kwargs) + if extra_attrs: + attrs.update(extra_attrs) + return attrs class Input(Widget): template_name = 'floppyforms/input.html'