As discussed in Issue 24342 <https://code.djangoproject.com/ticket/24342>, 
I've got an implementation of EnumField that we've found useful when 
developing our django REST API that I'd like to add to django core. It was 
suggested I bring this issue up in the developers mailing list for 
discussion. Unfortunately, updates to the issue were delivered to my spam 
folder, so there has been some delay in actually raising the issue.

Basically, the implementation consists of a new field type, and a new 
migration operation (to register the values associated with an enum type). 
The field takes an `enum_type` argument and registers a type with values 
taken from the enum value names. The actual values associated with the 
names are ignored, so support for IntEnum and other enum types comes as 
standard.

In a real implementation, the enum type would have to be checked when 
running migrations to ensure that values haven't been added/removed from 
the python class. It's not something that we've needed to deal with in our 
in-house implementation.

Any database which does not support an enum field natively would default to 
a CharField implementation. 

Useful addition? Or does it overlap too much with the choices API? 

Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/59072aa1-7e7a-4fcf-8dd1-effde66675c6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to