bckohan / django-enum

Full and natural support for enumerations as Django model fields.
https://django-enum.rtfd.io
MIT License
40 stars 1 forks source link

Support dataclass enums. #58

Open bckohan opened 8 months ago

bckohan commented 8 months ago

https://docs.python.org/3/howto/enum.html#enum-dataclass-support

enum properties is still a better way to do this - but not being part of stdlib more folks will use dataclass enumerations so django-enum should support it.

This will require adding another kwarg to the EnumField constructor that allows developers to specify the 'value' field on the dataclass.

bckohan commented 1 month ago

This might be OBE by #19

bckohan commented 1 month ago

I explored this in this branch https://github.com/bckohan/django-enum/tree/dataclasses

Its more involved than I hoped. Certainly not impossible, but I put pause on it because #19 might satisfy this for the general case on every RDBMS but sqlite which does not yet support enumeration column types.