Skip to content
This repository has been archived by the owner on Oct 1, 2020. It is now read-only.

Commit

Permalink
bug fix: pass request in context to recipient serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
monty5811 committed Aug 9, 2016
1 parent aac6016 commit 22bab4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def get_recipient(self, obj):
pk = self._split_args(obj.args)[0]
if pk is not None:
grp = Recipient.objects.get(pk=pk)
serializer = RecipientSerializer(grp)
serializer = RecipientSerializer(grp, context=self.context)
return serializer.data
else:
return {'url': '#', 'full_name': 'n/a'}
Expand Down
7 changes: 6 additions & 1 deletion api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ def get_queryset(self):
objs = objs.filter(**self.filters)
return objs

def get_serializer_context(self):
context = super(ApiCollection, self).get_serializer_context()
context['request'] = self.request
return context


class ApiCollectionRecentSms(ApiCollection):
"""SMS collection for a single recipient."""
Expand Down Expand Up @@ -168,7 +173,7 @@ def post(self, request, format=None, **kwargs):
obj.delete()
return r

serializer = self.serializer_class(obj)
serializer = self.serializer_class(obj, context={'request': request})
return Response(serializer.data)


Expand Down

0 comments on commit 22bab4d

Please sign in to comment.