Opened 5 years ago
Last modified 5 years ago
#30998 closed New feature
Make it easier to use the model instance in ChoiceWidget.create_option() — at Initial Version
Reported by: | Jon Dufresne | Owned by: | nobody |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I often find myself needing to add extra attributes to subwdiget HTML elements that depend on the model instance object. For example, HTML data-*
attributes.
Others have had similar needs and created their own solutions. For example: <http://srcmvn.com/blog/2013/01/15/django-advanced-model-choice-field/>.
As this isn't built-in, there have been some backward incompatible changes on some releases: #27758.
This ticket proposes to make this feature built-in to remove the need for third party applications to copy this boilerplate.
---
Right now, the ModelChoiceField.iterator
and `ModelChoiceIterator aren't documented. We could take this opportunity to do so if desired.