Opened 4 hours ago

Closed 3 hours ago

#36240 closed New feature (wontfix)

Store original choices Enum on the model field

Reported by: Evstifeev Roman Owned by:
Component: Database layer (models, ORM) Version: 5.1
Severity: Normal Keywords:
Cc: Evstifeev Roman Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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 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.

Change History (1)

comment:1 by Sarah Boyce, 3 hours ago

Resolution: wontfix
Status: newclosed
Type: UncategorizedNew feature

Hi

This appears to be requesting a new feature for Django. For cases like this, the recommended path forward is to first propose and discuss the idea with the community and gain consensus. To do that, please consider starting a new conversation on the Django Forum, where you'll reach a broader audience and receive additional feedback.

I'll close the ticket for now, but if the community agrees with the proposal, please return to this ticket and reference the forum discussion so we can re-open it. For more information, please refer to the documented guidelines for requesting features.

Thanks!

Note: See TracTickets for help on using tickets.
Back to Top