mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-24 23:19:47 +03:00
Merge 47095594de
into 8f23b7f2f9
This commit is contained in:
commit
a8b66f61d1
|
@ -384,6 +384,10 @@ class ManyRelatedMixin(object):
|
|||
else:
|
||||
if value == ['']:
|
||||
value = []
|
||||
|
||||
if value is None and self.required:
|
||||
raise ValidationError("Field '%s' is required" % field_name)
|
||||
|
||||
into[field_name] = [self.from_native(item) for item in value]
|
||||
|
||||
|
||||
|
|
|
@ -411,6 +411,14 @@ class ManyToManyTests(TestCase):
|
|||
self.assertEquals(instance.pk, 1)
|
||||
self.assertEquals(list(instance.rel.all()), [])
|
||||
|
||||
def test_create_relationship_missing(self):
|
||||
"""
|
||||
Create an instance of a model with a missing ManyToMany relationship
|
||||
"""
|
||||
data = {}
|
||||
serializer = self.serializer_class(data=data)
|
||||
self.assertEqual(serializer.is_valid(), False)
|
||||
|
||||
def test_create_empty_relationship_flat_data(self):
|
||||
"""
|
||||
Create an instance of a model with a ManyToMany relationship,
|
||||
|
|
Loading…
Reference in New Issue
Block a user