Opened 18 months ago
Closed 18 months ago
#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?)
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.