Commit 71dd870e authored by gushitong's avatar gushitong

Fix field not null validate.

parent ca01faad
...@@ -51,7 +51,14 @@ class MagicField(models.Field): ...@@ -51,7 +51,14 @@ class MagicField(models.Field):
:return: :return:
""" """
if value is None: if value is None:
return None if self.null:
return value
else:
raise exceptions.ValidationError(
self.error_messages['null'],
code=['null'],
params={'value': value, 'type': str(self.type)}
)
if hasattr(value, 'id'): if hasattr(value, 'id'):
return self.type(value.id) return self.type(value.id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment