def serialize(self, **extra_context): context = { 'request': self.request, 'view': self.view, } context.update(extra_context) serializer = ReviewSerializer(context=context) return serializer.to_representation(self.review)
def test_readonly_fields(self): serializer = ReviewSerializer(context={'request': self.request}) assert serializer.fields['created'].read_only is True assert serializer.fields['id'].read_only is True assert serializer.fields['reply'].read_only is True assert serializer.fields['user'].read_only is True
def serialize(self): serializer = ReviewSerializer(context={'request': self.request}) return serializer.to_representation(self.review)