Skip to content

Raise error when attempting to save serializer if data is not valid. #2098

Closed
@j0hnsmith

Description

@j0hnsmith

I'm seeing some unexpected behaviour in v3

In [23]: MyModel.objects.count()
Out[23]: 0

In [24]: s = MyModelSerializer(data={'foo': 'bar'})

In [25]: s.is_valid()
Out[25]: False

In [26]: s.errors
Out[26]: ReturnDict([('baz', [u'This field is required.'])])

In [27]: s.save()
Out[27]: <MyModel: MyModel object>

In [28]: MyModel.objects.count()
Out[28]: 1

Not necessarily a problem but perhaps worth a note in the docs.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions