Skip to content

Commit cad3717

Browse files
committed
Add documentation
1 parent ecdbae3 commit cad3717

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/settings.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,32 @@ Default: ``False``
140140
# 'messages': ['This field is required.'],
141141
# }
142142
# ]
143+
144+
145+
``DJANGO_CHOICE_FIELD_ENUM_V3_NAMING``
146+
--------------------------------------
147+
148+
Set to ``True`` to use the new naming format for the auto generated Enum types from Django choice fields. The new format looks like this: ``DjangoModel{app_label}{object_name}{field_name}Choices``
149+
150+
Default: ``False``
151+
152+
153+
``DJANGO_CHOICE_FIELD_ENUM_CUSTOM_NAME``
154+
--------------------------------------
155+
156+
Set to a function that takes the Django choice field and returns a string to completely customise the naming for the Enum type.
157+
158+
If set to a function then the ``DJANGO_CHOICE_FIELD_ENUM_V3_NAMING`` setting is ignored.
159+
160+
Default: ``None``
161+
162+
.. code:: python
163+
164+
def enum_naming(field):
165+
if isinstance(field.model, User):
166+
return f"CustomUserEnum{field.name.title()}"
167+
return f"CustomEnum{field.name.title()}"
168+
169+
GRAPHENE = {
170+
'DJANGO_CHOICE_FIELD_ENUM_CUSTOM_NAME': enum_naming
171+
}

0 commit comments

Comments
 (0)