[Django] #28308: In 1.11 does not call the function render_option in custom widget (forms.widgets.Select)

5 views
Skip to first unread message

Django

unread,
Jun 14, 2017, 6:01:47 AM6/14/17
to django-...@googlegroups.com
#28308: In 1.11 does not call the function render_option in custom widget
(forms.widgets.Select)
-------------------------------------+-------------------------------------
Reporter: noxxer | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 1.11
Severity: Normal | Keywords: forms, widgets,
Triage Stage: | Select, render_option
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
Checked and compared the rendering of the form in 1.10 and 1.11. In
version 1.11, the method render_option ceased to be called.

{{{
class SelectWithData(forms.widgets.Select):
def __init__(self, *args, **kwargs):
self.options_data = kwargs.pop('options_data', None)
super(SelectWithData, self).__init__(*args, **kwargs)

def render_option(self, selected_choices, option_value, option_label):
if self.options_data and option_value in self.options_data:
price=''
if 'price' in self.options_data[option_value]:
price = self.options_data[option_value]['price']
html = u'<option value="{}" price="{}" >{}</option>'.format(
escape(option_value),
price,
conditional_escape(force_unicode(option_label)))
else:
# No options_data
option_value = force_unicode(option_value)
html = u'<option value="{}">{}</option>'.format(
escape(option_value),
conditional_escape(force_unicode(option_label)))
return html

class MyForm(forms.Form):
state = forms.ChoiceField(widget=forms.SelectWithData(choices=[]))
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28308>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jun 14, 2017, 6:15:07 AM6/14/17
to django-...@googlegroups.com
#28308: In 1.11 does not call the function render_option in custom widget
(forms.widgets.Select)
-------------------------------------+-------------------------------------
Reporter: noxxer | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 1.11
Severity: Normal | Resolution: fixed

Keywords: forms, widgets, | Triage Stage:
Select, render_option | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"f2b698631719c6df082a627b6f7ddf2d7f9fa751" f2b69863]:
{{{
#!CommitTicketReference repository=""
revision="f2b698631719c6df082a627b6f7ddf2d7f9fa751"
Fixed #28308 -- Doc'd removal of Select.render_option() (refs #15667).
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28308#comment:1>

Django

unread,
Jun 14, 2017, 6:15:18 AM6/14/17
to django-...@googlegroups.com
#28308: In 1.11 does not call the function render_option in custom widget
(forms.widgets.Select)
-------------------------------------+-------------------------------------
Reporter: noxxer | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 1.11
Severity: Normal | Resolution: fixed

Keywords: forms, widgets, | Triage Stage:
Select, render_option | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"f20168e873d9c55b66aa49aee85d9e4804697afb" f20168e8]:
{{{
#!CommitTicketReference repository=""
revision="f20168e873d9c55b66aa49aee85d9e4804697afb"
[1.11.x] Fixed #28308 -- Doc'd removal of Select.render_option() (refs
#15667).

Backport of f2b698631719c6df082a627b6f7ddf2d7f9fa751 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/28308#comment:2>

Django

unread,
Jun 14, 2017, 6:16:40 AM6/14/17
to django-...@googlegroups.com
#28308: Document removal of Select.render_option()

-------------------------------------+-------------------------------------
Reporter: noxxer | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Documentation | Version: 1.11
Severity: Normal | Resolution: fixed
Keywords: forms, widgets, | Triage Stage: Accepted
Select, render_option |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* component: Forms => Documentation
* stage: Unreviewed => Accepted
* type: Bug => Cleanup/optimization


Comment:

Usually we don't document removal of undocumented APIs but I suppose it
doesn't hurt here.

--
Ticket URL: <https://code.djangoproject.com/ticket/28308#comment:3>

Reply all
Reply to author
Forward
0 new messages