mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-11 04:07:39 +03:00
Test deserialising data including None
fk
This commit is contained in:
parent
20d1fdba69
commit
cbb8d8d254
|
@ -49,7 +49,7 @@ class NullableUUIDForeignKeySourceSerializer(serializers.ModelSerializer):
|
|||
target = serializers.PrimaryKeyRelatedField(
|
||||
pk_field=serializers.UUIDField(),
|
||||
queryset=UUIDForeignKeyTarget.objects.all(),
|
||||
allow_empty=True)
|
||||
allow_null=True)
|
||||
|
||||
class Meta:
|
||||
model = NullableUUIDForeignKeySource
|
||||
|
@ -451,6 +451,11 @@ class PKNullableForeignKeyTests(TestCase):
|
|||
data = serializer.data
|
||||
self.assertEqual(data["target"], None)
|
||||
|
||||
def test_nullable_uuid_foreign_key_is_valid_when_none(self):
|
||||
data = {"name": "Source", "target": None}
|
||||
serializer = NullableUUIDForeignKeySourceSerializer(data=data)
|
||||
self.assertTrue(serializer.is_valid(), serializer.errors)
|
||||
|
||||
|
||||
class PKNullableOneToOneTests(TestCase):
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in New Issue
Block a user