Comment (by Claude Paroz):
I'm not yet sure about the implementation (didn't find time until now),
but basically, we should be able to handle the following use cases:
- attrs for parent widget, not on subwidgets (already OK with
`option_inherits_attrs` set to `False`)
- same attrs for parent widget AND subwidgets (already OK with
`option_inherits_attrs` set to `True`)
- attrs for subwidgets but NOT for parent widget (<-- TODO)
Ideally I would like to be able to do that without subclassing, e.g. by
`Widget(attrs={...}, option_attrs={...})`. I guess experiments will tell
if it's doable wrt option attrs inheritance.
--
Ticket URL: <https://code.djangoproject.com/ticket/34034#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by David Smith):
Seems a reasonable suggestion to me.
One other thought I had was about using templates. A custom template could
be provided to `option_template_name` or
`"django/forms/widgets/select_option.html"` could be overridden. This may
help to avoid `Widget(attrs={...}, option_attrs={...})` each time this
type of widget is used in a project?
--
Ticket URL: <https://code.djangoproject.com/ticket/34034#comment:5>
Comment (by Claude Paroz):
The problem with templates is that it's also very difficult to add
classes, as they may conflict with other classes already present in
`attrs`. If there was a mean to complement widget/subwidget classes from
`attrs` with custom classes, then templates could be a viable solution.
--
Ticket URL: <https://code.djangoproject.com/ticket/34034#comment:6>
* owner: nobody => Kees Hink
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/34034#comment:7>
* has_patch: 0 => 1
Comment:
https://github.com/django/django/pull/16929
--
Ticket URL: <https://code.djangoproject.com/ticket/34034#comment:8>
* needs_better_patch: 0 => 1
* needs_tests: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/34034#comment:9>
* owner: Kees Hink => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/34034#comment:10>
* owner: (none) => Mariana
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/34034#comment:11>