1
0
mirror of https://github.com/django/django.git synced 2025-04-14 20:34:36 +00:00

3 Commits

Author SHA1 Message Date
Carlton Gibson
8740ff334a [3.0.x] Fixed #30902 -- Added __str__() for model choice enums.
Allows expected behavior when cast to str, also matching behaviour of
created instances with those fetched from the DB.

Thanks to Simon Charette, Nick Pope, and Shai Berger for reviews.

Backport of dbcd7b064e7278614f29fc45468d461e263d4da7 from master
2019-10-25 09:38:41 +02:00
Mariusz Felisiak
74c5ddc657 [3.0.x] Refs #27910 -- Added __init__.py file for model_enums tests.
Backport of 1877ec18753947795b7821f8b9176bd7ea7c03a3 from master
2019-10-15 21:28:17 +02:00
Shai Berger
72ebe85a26 Fixed #27910 -- Added enumeration helpers for use in Field.choices.
These classes can serve as a base class for user enums, supporting
translatable human-readable names, or names automatically inferred
from the enum member name.

Additional properties make it easy to access the list of names, values
and display labels.

Thanks to the following for ideas and reviews:

Carlton Gibson, Fran Hrženjak, Ian Foote, Mariusz Felisiak, Shai Berger.

Co-authored-by: Shai Berger <shai@platonix.com>
Co-authored-by: Nick Pope <nick.pope@flightdataservices.com>
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2019-09-04 14:42:49 +02:00