diff --git a/rest_framework_bulk/drf3/serializers.py b/rest_framework_bulk/drf3/serializers.py index 9098829..31fff46 100644 --- a/rest_framework_bulk/drf3/serializers.py +++ b/rest_framework_bulk/drf3/serializers.py @@ -1,4 +1,6 @@ from __future__ import print_function, unicode_literals +import inspect + from rest_framework.exceptions import ValidationError from rest_framework.serializers import ListSerializer @@ -41,6 +43,10 @@ def update(self, queryset, all_validated_data): for i in all_validated_data } + if not all((bool(i) and not inspect.isclass(i) + for i in all_validated_data_by_id.keys())): + raise ValidationError('') + # since this method is given a queryset which can have many # model instances, first find all objects to update # and only then update the models diff --git a/rest_framework_bulk/tests/test_generics.py b/rest_framework_bulk/tests/test_generics.py index 51bdb15..6838bf4 100644 --- a/rest_framework_bulk/tests/test_generics.py +++ b/rest_framework_bulk/tests/test_generics.py @@ -1,6 +1,5 @@ from __future__ import unicode_literals, print_function import json -import unittest from django.core.urlresolvers import reverse from django.test import TestCase @@ -85,7 +84,6 @@ def test_put(self): ] ) - @unittest.skip('') def test_put_without_update_key(self): """ Test that PUT request updates all submitted resources. @@ -94,6 +92,7 @@ def test_put_without_update_key(self): '', json.dumps([ {'contents': 'foo', 'number': 3}, + {'contents': 'rainbows', 'number': 4}, # multiple objects without id {'contents': 'bar', 'number': 4, 'id': 555}, # non-existing id ]), content_type='application/json',