#32460: TextChoices/IntegerChoices can not have a member with name `label`
-------------------------------------+-------------------------------------
Reporter: elonzh | Owner: Nick Pope
Type: Bug | Status: assigned
Component: Database layer | Version: 3.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: Choices | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by elonzh):
Replying to [comment:2 Nick Pope]:
> Hi. Thanks for the report.
>
> So looking at this, I don't think that making it possible to customise
the `.label` property name is the right approach.
>
> `Enum` doesn't have a problem providing `.name` or `.value` attributes
on the members while still allowing those names to be used as member
names.
> I have something sorted out that will fix this for `.label` and
`.do_not_call_in_templates` (although the latter is rather niche!)
>
> This is also broken for `.names`, `.values`, `.labels`, and `.choices`.
These are, however, probably not fixable as they must exist on the top-
level class itself and not the members, so they would collide with the
member names. Perhaps this part of the problem can be addressed with some
documentation.
>
> Alternate [https://github.com/django/django/pull/14022 PR].
using methods to get such members? like `get_labels()`, these methods
introduce API changes but I think it's a clear solution?
--
Ticket URL: <https://code.djangoproject.com/ticket/32460#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/064.1a48ef8d0b9b8521e2bc0ec5ad13bcc3%40djangoproject.com.