[Django] #34596: subclassing models.TextChoices

3 views
Skip to first unread message

Django

unread,
May 25, 2023, 3:37:01 AM5/25/23
to django-...@googlegroups.com
#34596: subclassing models.TextChoices
-----------------------------------------+------------------------
Reporter: piscvau | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 4.2
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 |
-----------------------------------------+------------------------
Would it be possible to clarify in the documentation whether it is
possible or not to subclass one of the enums.Choices classes.
The purpose would be for example to add a third attribute to the class.
Here the question was raised one year and a half ago and no response is
yet available.
https://stackoverflow.com/questions/69091496/best-way-to-add-third-
attribute-to-django-models-choices
If it is possible, a hint on how to do it would be helpful (rewrite a
__new__).
If it is not possible may be a hint on the best way would be
helpful(define a custom field?)

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

Django

unread,
May 25, 2023, 4:11:40 AM5/25/23
to django-...@googlegroups.com
#34596: subclassing models.TextChoices
-------------------------------+--------------------------------------
Reporter: piscvau | Owner: nobody
Type: Uncategorized | Status: closed
Component: Documentation | Version: 4.2
Severity: Normal | Resolution: invalid

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

Thanks for this ticket, however we cannot document everything, that's why
there are support channels and sites like StackOverflow. Subclassing
`TextChoices` is not officially forbidden or supported, sky's the limit.
Personally, I wouldn't hesitate to do so if you have a valid use case.

--
Ticket URL: <https://code.djangoproject.com/ticket/34596#comment:1>

Reply all
Reply to author
Forward
0 new messages