Add required param `renderer` to Widget.render

Added on Django 1.11 and required since 2.1
The renderer argument is added to the Widget.render() method.
https://docs.djangoproject.com/en/2.1/releases/1.11/#id2
This commit is contained in:
Santiago L 2021-05-13 11:52:34 +02:00
parent 7183174f4c
commit 5a21f766b4
1 changed files with 6 additions and 6 deletions

View File

@ -17,9 +17,9 @@ class SpanWidget(forms.Widget):
self.original = kwargs.pop('original', '') self.original = kwargs.pop('original', '')
self.display = kwargs.pop('display', None) self.display = kwargs.pop('display', None)
super(SpanWidget, self).__init__(*args, **kwargs) super(SpanWidget, self).__init__(*args, **kwargs)
def render(self, name, value, attrs=None): def render(self, name, value, attrs=None, renderer=None):
final_attrs = self.build_attrs(attrs, name=name) final_attrs = self.build_attrs(attrs, extra_attrs={'name':name})
original = self.original or value original = self.original or value
display = original if self.display is None else self.display display = original if self.display is None else self.display
# Display icon # Display icon
@ -29,10 +29,10 @@ class SpanWidget(forms.Widget):
tag = self.tag[:-1] tag = self.tag[:-1]
endtag = '/'.join((self.tag[0], self.tag[1:])) endtag = '/'.join((self.tag[0], self.tag[1:]))
return mark_safe('%s%s >%s%s' % (tag, forms.utils.flatatt(final_attrs), display, endtag)) return mark_safe('%s%s >%s%s' % (tag, forms.utils.flatatt(final_attrs), display, endtag))
def value_from_datadict(self, data, files, name): def value_from_datadict(self, data, files, name):
return self.original return self.original
def _has_changed(self, initial, data): def _has_changed(self, initial, data):
return False return False
@ -61,7 +61,7 @@ class DynamicHelpTextSelect(forms.Select):
attrs.update(kwargs.get('attrs', {})) attrs.update(kwargs.get('attrs', {}))
kwargs['attrs'] = attrs kwargs['attrs'] = attrs
super(DynamicHelpTextSelect, self).__init__(*args, **kwargs) super(DynamicHelpTextSelect, self).__init__(*args, **kwargs)
def get_dynamic_help_text(self, target, help_text): def get_dynamic_help_text(self, target, help_text):
return textwrap.dedent("""\ return textwrap.dedent("""\
siteoptions = {help_text}; siteoptions = {help_text};