From 41364b3be0536a606d9b41d3792c2e562b860360 Mon Sep 17 00:00:00 2001 From: Fernando Rocha Date: Wed, 30 Jan 2013 09:09:17 -0300 Subject: [PATCH] Added regretion test for issue #632 Signed-off-by: Fernando Rocha --- rest_framework/tests/relations.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/rest_framework/tests/relations.py b/rest_framework/tests/relations.py index 91daea8a6..edc85f9ea 100644 --- a/rest_framework/tests/relations.py +++ b/rest_framework/tests/relations.py @@ -31,3 +31,17 @@ class FieldTests(TestCase): field = serializers.SlugRelatedField(queryset=NullModel.objects.all(), slug_field='pk') self.assertRaises(serializers.ValidationError, field.from_native, '') self.assertRaises(serializers.ValidationError, field.from_native, []) + + +class TestManyRelateMixin(TestCase): + def test_missing_many_to_many_related_field(self): + ''' + Regression test for #632 + + https://github.com/tomchristie/django-rest-framework/pull/632 + ''' + field = serializers.ManyRelatedField(read_only=False) + + into = {} + field.field_from_native({}, None, 'field_name', into) + self.assertEqual(into['field_name'], [])