From 248afdbaa1c4d4a6e16cc8323e26b9eebef30d65 Mon Sep 17 00:00:00 2001 From: "Terence D. Honles" Date: Tue, 29 Aug 2017 14:56:01 -0700 Subject: [PATCH] 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 --- extras_mongoengine/fields.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extras_mongoengine/fields.py b/extras_mongoengine/fields.py index 5871ddf..7ce8264 100644 --- a/extras_mongoengine/fields.py +++ b/extras_mongoengine/fields.py @@ -75,7 +75,8 @@ class EnumField(object): def __init__(self, enum, *args, **kwargs): self.enum = enum - kwargs['choices'] = [choice for choice in enum] + if 'choices' not in kwargs: + kwargs['choices'] = [(c.value, c.name) for c in enum] super(EnumField, self).__init__(*args, **kwargs) def __get_value(self, enum):