Simplified Widget.get_context() a bit.
This commit is contained in:
parent
83c631ade7
commit
b2ef3d7157
|
@ -225,16 +225,16 @@ class Widget(metaclass=MediaDefiningClass):
|
||||||
return str(value)
|
return str(value)
|
||||||
|
|
||||||
def get_context(self, name, value, attrs):
|
def get_context(self, name, value, attrs):
|
||||||
context = {}
|
return {
|
||||||
context['widget'] = {
|
'widget': {
|
||||||
'name': name,
|
'name': name,
|
||||||
'is_hidden': self.is_hidden,
|
'is_hidden': self.is_hidden,
|
||||||
'required': self.is_required,
|
'required': self.is_required,
|
||||||
'value': self.format_value(value),
|
'value': self.format_value(value),
|
||||||
'attrs': self.build_attrs(self.attrs, attrs),
|
'attrs': self.build_attrs(self.attrs, attrs),
|
||||||
'template_name': self.template_name,
|
'template_name': self.template_name,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
return context
|
|
||||||
|
|
||||||
def render(self, name, value, attrs=None, renderer=None):
|
def render(self, name, value, attrs=None, renderer=None):
|
||||||
"""Render the widget as an HTML string."""
|
"""Render the widget as an HTML string."""
|
||||||
|
|
Loading…
Reference in New Issue