-
Notifications
You must be signed in to change notification settings - Fork 768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add options to override how Django Choice fields are converted to Enums #860
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While introducing new settings is to be avoided, both have their rationale.
DJANGO_CHOICE_FIELD_ENUM_V3_NAMING
is a path forward to conflict free defaults.
DJANGO_CHOICE_FIELD_ENUM_CUSTOM_NAME
does take away control from the applications for extreme remedies. However it appears to encourage importing models into the settings, this should be avoided. Instead we should support a string to be imported using https://docs.djangoproject.com/en/3.0/_modules/django/utils/module_loading/
@zbyte64 good point about using module loading rather than direct references. I'll update the PR. Also I don't understand the rest of your comment? Are you suggesting changes to the documentation or just re-iterating what the purpose of the change is? |
Was just re-iterating / thinking out loud. Updating the settings to allow a string specified import was my only recommend action. |
Co-Authored-By: Syrus Akbary <me@syrusakbary.com>
75b0c69
to
9cff365
Compare
@zbyte64 PR is ready for another review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for tackling this
When is this going to be merged? |
Someone merge and deploy this please |
Sorry for the delay with this (I've been on holiday). Shipping this now |
This PR resolves #185 and #843 by adding 2 new settings to customise the naming of the Enum types generated from Django Choice fields.
DJANGO_CHOICE_FIELD_ENUM_V3_NAMING
changes all enum type names to a naming convention that should prevent duplicates. This format will be the default in v3.DJANGO_CHOICE_FIELD_ENUM_CUSTOM_NAME
allows you to define a custom function to determine what the enum type name should be