Skip to content

Commit 248afdb

Browse files
committed
choices generated only if not provided and items are tuples
Choices should conform to https://docs.djangoproject.com/en/1.11/ref/models/fields/#choices
1 parent 5e63e05 commit 248afdb

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

extras_mongoengine/fields.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ class EnumField(object):
7575

7676
def __init__(self, enum, *args, **kwargs):
7777
self.enum = enum
78-
kwargs['choices'] = [choice for choice in enum]
78+
if 'choices' not in kwargs:
79+
kwargs['choices'] = [(c.value, c.name) for c in enum]
7980
super(EnumField, self).__init__(*args, **kwargs)
8081

8182
def __get_value(self, enum):

0 commit comments

Comments
 (0)