Added django style choices
This commit is contained in:
parent
ef15733efe
commit
e1282028a5
@ -100,9 +100,9 @@ class BaseField(object):
|
|||||||
def _validate(self, value):
|
def _validate(self, value):
|
||||||
# check choices
|
# check choices
|
||||||
if self.choices is not None:
|
if self.choices is not None:
|
||||||
if value not in self.choices:
|
option_keys = [option_key for option_key, option_value in self.choices]
|
||||||
raise ValidationError("Value must be one of %s."
|
if value not in option_keys:
|
||||||
% unicode(self.choices))
|
raise ValidationError("Value must be one of %s." % unicode(option_keys))
|
||||||
|
|
||||||
# check validation argument
|
# check validation argument
|
||||||
if self.validation is not None:
|
if self.validation is not None:
|
||||||
|
@ -12,7 +12,6 @@ import datetime
|
|||||||
import decimal
|
import decimal
|
||||||
import gridfs
|
import gridfs
|
||||||
import warnings
|
import warnings
|
||||||
import types
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['StringField', 'IntField', 'FloatField', 'BooleanField',
|
__all__ = ['StringField', 'IntField', 'FloatField', 'BooleanField',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user