From 14af7c739ec48cf25537294f113893c45d133e9b Mon Sep 17 00:00:00 2001 From: Martin Maillard Date: Thu, 27 Nov 2014 21:43:06 +0100 Subject: [PATCH] Pass context to `base_serializer` in `SideloadListSerializer` If the base serializer needs to access, for exemple, the request, we need to pass the context. --- ember_drf/serializers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ember_drf/serializers.py b/ember_drf/serializers.py index 76dd90c..ea7c2be 100644 --- a/ember_drf/serializers.py +++ b/ember_drf/serializers.py @@ -140,7 +140,11 @@ def to_representation(self, instance): Overrides to nest the primary record and add sideloads. """ ret = OrderedDict() - base_data = self.base_serializer.__class__(instance, many=True).data + base_data = self.base_serializer.__class__( + instance, + many=True, + context=self.context + ).data ret[pluralize(self.base_key)] = base_data ret.update(self.get_sideload_objects(instance)) return ret