Simplified Widget.get_context() a bit.

This commit is contained in:
Jon Dufresne 2020-05-05 16:43:13 -07:00 committed by Mariusz Felisiak
parent 83c631ade7
commit b2ef3d7157
1 changed files with 9 additions and 9 deletions

View File

@ -225,16 +225,16 @@ class Widget(metaclass=MediaDefiningClass):
return str(value)
def get_context(self, name, value, attrs):
context = {}
context['widget'] = {
'name': name,
'is_hidden': self.is_hidden,
'required': self.is_required,
'value': self.format_value(value),
'attrs': self.build_attrs(self.attrs, attrs),
'template_name': self.template_name,
return {
'widget': {
'name': name,
'is_hidden': self.is_hidden,
'required': self.is_required,
'value': self.format_value(value),
'attrs': self.build_attrs(self.attrs, attrs),
'template_name': self.template_name,
},
}
return context
def render(self, name, value, attrs=None, renderer=None):
"""Render the widget as an HTML string."""