aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/tests/relations.py
diff options
context:
space:
mode:
Diffstat (limited to 'rest_framework/tests/relations.py')
-rw-r--r--rest_framework/tests/relations.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/rest_framework/tests/relations.py b/rest_framework/tests/relations.py
index f28f0de9..d19219c9 100644
--- a/rest_framework/tests/relations.py
+++ b/rest_framework/tests/relations.py
@@ -80,3 +80,21 @@ class RelatedFieldSourceTests(TestCase):
obj = ClassWithQuerysetMethod()
value = field.field_to_native(obj, 'field_name')
self.assertEqual(value, ['BlogPost object'])
+
+ def test_dotted_source(self):
+ """
+ Source argument should support dotted.source notation.
+ """
+ BlogPost.objects.create(title='blah')
+ field = serializers.RelatedField(many=True, source='a.b.c')
+
+ class ClassWithQuerysetMethod(object):
+ a = {
+ 'b': {
+ 'c': BlogPost.objects.all()
+ }
+ }
+
+ obj = ClassWithQuerysetMethod()
+ value = field.field_to_native(obj, 'field_name')
+ self.assertEqual(value, ['BlogPost object'])