Accessing query parameter in serializer in Django

I just wanted to access a query parameter in serializer like

class MySerializer(serializers.ModelSerializer):
    isHighlight = serializers.SerializerMethodField()

    def get_isHighlight(self, obj):
        return self.context['request'].query_params['page']

But its showing

Django Version: 3.2.7
Exception Type: KeyError
Exception Value: 'request'

Thanks in advance.

Back to Top