0
Use standard models.TextChoices which can optionally accepts translation too:
from django.utils.translation import gettext_lazy as _
class Status(models.TextChoices):
APPROVED = 'APPROVED', _('Approved')
CANCELED = 'CANCELED', _('Canceled')
0
If you’re looking to support multiple languages, take a look at https://docs.djangoproject.com/en/4.1/topics/i18n/translation/
If you want to get the human-readable version of these enum values, there is a prebuilt function in Django called get_[fieldname]_display()
that returns the enum value rather than the key.
Source:stackexchange.com