DjangoRestMultipleModels icon indicating copy to clipboard operation
DjangoRestMultipleModels copied to clipboard

Is it possible to send context with the querylist?

Open asbin143 opened this issue 4 years ago • 1 comments

Actually i want to send extra argument with the serializer. Eg. serializer = PollDetailSerializer(context={"user_id": request.user.user_id})

asbin143 avatar Jun 23 '20 11:06 asbin143

@asbin143

I too had this requirement using this package. There is a way to override the get_serializer_context method just like this

def get_serializer_context(self):
    context = super(CLASS_VIEWSET_NAME, self).get_serializer_context()
    context.update({"user_id": self.request.user.user_id})
    return context

Naveenkorkopp avatar Apr 19 '21 19:04 Naveenkorkopp