Commit 88955836 by J. Paul Reed Committed by J. Paul Reed

Don't have the ModelSerializer trust deserialized objects to not have redefine bool()ean-ness.

If the model we're using the ModelSerializer for has redefined methods that act as a boolean (__bool__ or __len__), it may not return the object even though it is_valid(), and should.
parent 5ed70324
...@@ -741,7 +741,7 @@ class ModelSerializer(Serializer): ...@@ -741,7 +741,7 @@ class ModelSerializer(Serializer):
Override the default method to also include model field validation. Override the default method to also include model field validation.
""" """
instance = super(ModelSerializer, self).from_native(data, files) instance = super(ModelSerializer, self).from_native(data, files)
if instance: if not self._errors:
return self.full_clean(instance) return self.full_clean(instance)
def save_object(self, obj, **kwargs): def save_object(self, obj, **kwargs):
......
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