#31261: Add support for defining models.Choices fields with dict, tuple, set and
list values.
-------------------------------------+-------------------------------------
Reporter: Tom Forbes | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Shai Berger):
Replying to [comment:4 felixxm]:
> Replying to [comment:2 Adam (Chainz) Johnson]:
> > As I wrote on the forum post, we can detect if dict/list/set/tuple is
in the MRO and disable this functionality in those (probably very rare)
cases.
>
> Can we? e.g.
[https://github.com/django/django/blob/master/tests/model_enums/tests.py#L179-L185
MoonLandings] each option is defined by tuple but none of them is a group.
I'm pretty sure we can't. The way Enums work is that the value assigned to
elements in the code is not an instance of the target type, but rather a
set of arguments for constructing one.
Further, an important part of `Choices` is the fact you can add
(translatable) display strings, as a last element of a tuple.
--
Ticket URL: <https://code.djangoproject.com/ticket/31261#comment:7>
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/061.e7d763e1937af2c83778ba08af27f12a%40djangoproject.com.