#32110 closed Cleanup/optimization (fixed)
Document using an Enum class in form Field choices
Reported by: | Claude Paroz | Owned by: | Claude Paroz |
---|---|---|---|
Component: | Forms | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Ready for checkin | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description (last modified by )
Similarly to what was done for model fields, it would be nice to have the choices
form field attribute also support enum data.
Change History (9)
comment:1 by , 4 years ago
Description: | modified (diff) |
---|
comment:2 by , 4 years ago
Easy pickings: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 4 years ago
I'm not so sure if this is already supported or not. But let's add some tests for that and they will tell us!
comment:4 by , 4 years ago
Has patch: | set |
---|---|
Summary: | Allow using an Enum class in form Field choices → Document using an Enum class in form Field choices |
My suspicions were wrong, it is well supported. PR with test and docs: PR.
comment:5 by , 4 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
Type: | New feature → Cleanup/optimization |
comment:6 by , 4 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
Note:
See TracTickets
for help on using tickets.
As we use
.choices
on the enum classes to return a list of tuples there isn't really any code to add to make this work AFAICT.So this perhaps could just be documented for forms pointing to the documentation at https://docs.djangoproject.com/en/stable/ref/models/fields/#field-choices-enum-types