[Django] #32110: Allow using an Enum class in form Field choices

4 views
Skip to first unread message

Django

unread,
Oct 15, 2020, 3:23:42 AM10/15/20
to django-...@googlegroups.com
#32110: Allow using an Enum class in form Field choices
----------------------------------------+------------------------
Reporter: Claude Paroz | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
----------------------------------------+------------------------
Similarly to what was done for model fields, it would be nice to have the
`choices` widget attribute also support enum data.

--
Ticket URL: <https://code.djangoproject.com/ticket/32110>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 15, 2020, 4:49:00 AM10/15/20
to django-...@googlegroups.com
#32110: Allow using an Enum class in form Field choices
------------------------------+------------------------------------

Reporter: Claude Paroz | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+------------------------------------
Changes (by Nick Pope):

* easy: 0 => 1
* stage: Unreviewed => Accepted


Comment:

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

--
Ticket URL: <https://code.djangoproject.com/ticket/32110#comment:2>

Django

unread,
Oct 15, 2020, 5:37:47 AM10/15/20
to django-...@googlegroups.com
#32110: Allow using an Enum class in form Field choices
------------------------------+------------------------------------

Reporter: Claude Paroz | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+------------------------------------

Comment (by Claude Paroz):

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!

--
Ticket URL: <https://code.djangoproject.com/ticket/32110#comment:3>

Django

unread,
Oct 17, 2020, 10:46:20 AM10/17/20
to django-...@googlegroups.com
#32110: Document using an Enum class in form Field choices
------------------------------+------------------------------------

Reporter: Claude Paroz | Owner: nobody
Type: New feature | Status: new
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
------------------------------+------------------------------------
Changes (by Claude Paroz):

* has_patch: 0 => 1


Comment:

My suspicions were wrong, it is well supported. PR with test and docs:
[https://github.com/django/django/pull/13550 PR].

--
Ticket URL: <https://code.djangoproject.com/ticket/32110#comment:4>

Django

unread,
Oct 17, 2020, 11:11:25 AM10/17/20
to django-...@googlegroups.com
#32110: Document using an Enum class in form Field choices
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Forms | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Jacob Walls):

* owner: nobody => Claude Paroz
* status: new => assigned
* type: New feature => Cleanup/optimization


--
Ticket URL: <https://code.djangoproject.com/ticket/32110#comment:5>

Django

unread,
Oct 17, 2020, 2:57:03 PM10/17/20
to django-...@googlegroups.com
#32110: Document using an Enum class in form Field choices
-------------------------------------+-------------------------------------
Reporter: Claude Paroz | Owner: Claude
Type: | Paroz
Cleanup/optimization | Status: assigned
Component: Forms | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/32110#comment:6>

Reply all
Reply to author
Forward
0 new messages