Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#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 Claude Paroz)

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 Claude Paroz, 4 years ago

Description: modified (diff)

comment:2 by Nick Pope, 4 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted

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

comment:3 by Claude Paroz, 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 Claude Paroz, 4 years ago

Has patch: set
Summary: Allow using an Enum class in form Field choicesDocument 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 Jacob Walls, 4 years ago

Owner: changed from nobody to Claude Paroz
Status: newassigned
Type: New featureCleanup/optimization

comment:6 by Mariusz Felisiak, 4 years ago

Triage Stage: AcceptedReady for checkin

comment:7 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

Resolution: fixed
Status: assignedclosed

In 7f85498e:

Fixed #32110 -- Doc'd and tested enumerations for ChoiceField.choices.

comment:8 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In 8caf524:

[3.1.x] Fixed #32110 -- Doc'd and tested enumerations for ChoiceField.choices.

Backport of 7f85498eef1d8fcc52e4fb70df8041f5452d405a from master

comment:9 by Mariusz Felisiak <felisiak.mariusz@…>, 4 years ago

In 72a17c91:

[3.0.x] Fixed #32110 -- Doc'd and tested enumerations for ChoiceField.choices.

Backport of 7f85498eef1d8fcc52e4fb70df8041f5452d405a from master

Note: See TracTickets for help on using tickets.
Back to Top