#34596 closed Uncategorized (invalid)

subclassing models.TextChoices

Reported by: piscvau Owned by: nobody
Component: Documentation Version: 4.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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?)

Change History (1)

comment:1 by Mariusz Felisiak, 12 months ago

Resolution: invalid
Status: newclosed

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.

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