Opened 5 years ago
Closed 5 years ago
#30998 closed New feature (fixed)
Make it easier to use the model instance in ChoiceWidget.create_option()
Reported by: | Jon Dufresne | Owned by: | Jon Dufresne |
---|---|---|---|
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 (last modified by )
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.
Change History (9)
comment:1 by , 5 years ago
Has patch: | set |
---|
comment:2 by , 5 years ago
Description: | modified (diff) |
---|---|
Needs documentation: | set |
Triage Stage: | Unreviewed → Accepted |
Hi Jon. Yes, super.
(We have this exact kind of thing in Django Filter.) I think it should be a documented pattern. The data-*
attribute is a nice example.
comment:3 by , 5 years ago
Needs documentation: | unset |
---|
Sounds good. I've documented the attribute and classes.
comment:4 by , 5 years ago
Needs documentation: | set |
---|
comment:5 by , 5 years ago
Needs documentation: | unset |
---|
comment:6 by , 5 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:7 by , 5 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Triage Stage: | Ready for checkin → Accepted |
https://github.com/django/django/pull/12088