#36240: Store original choices Enum on the model field -------------------------------------+------------------------------------- Reporter: Evstifeev Roman | Type: | Uncategorized Status: new | Component: Database | layer (models, ORM) Version: 5.1 | Severity: Normal Keywords: | Triage Stage: | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- The models filed can have choices provided in ''Enum'' (django.db.models.Choices). This original ''Enum'' class can't be retrieved from the field itself, as it only stores normalized list of (value, label) tuples in its `field.choices` property.
It would be useful to be able to retrieve the original ''Enum'' from the given model field during a process of building a json schema or pydantic model. One example of such use is [https://github.com/vitalik/django-ninja django-ninja] framework. Currently it is possible to rebuild similar ''Enum'' from the field with `field.choices` with `Enum('FieldChoices', field.choices)` but the original Enum name and any additional meta info defined on it is lost. -- Ticket URL: <https://code.djangoproject.com/ticket/36240> 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 django-updates+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/django-updates/010701957eb77079-c1789994-94fa-427f-a6d9-86a92cd256c6-000000%40eu-central-1.amazonses.com.