You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I provide data based on the user that is currently authenticated.
With DRF I simply access self.context.request. I see the serializer accepts the context object, but leaves it at None. Is this a choice by design or a feature to be implemented?
Dealbreaker for me in any case.
In terms of performance testing, FYI I am getting 50% gains compared to DRF. Which is significant and would be great to have in prod...!
The text was updated successfully, but these errors were encountered:
The context argument was added to the constructor to be compatible with DRF generic views and is currently not used. You can make a custom base serializer that sets the context, and then you'll be able to access it later:
classBaseSerializer(Serializer):
def__init__(self, instance=None, many=False, data=None, context=None, **kwargs):
self.context=contextsuper(BaseSerializer, self).__init__(instance, many, data, context, **kwargs)
# Then in your serializer:classMySerializer(BaseSerializer):
foo=MethodField()
defget_foo(self, obj):
# Access self.context>>>MySerializer(obj, context=context).data
I provide data based on the user that is currently authenticated.
With DRF I simply access self.context.request. I see the serializer accepts the context object, but leaves it at None. Is this a choice by design or a feature to be implemented?
Dealbreaker for me in any case.
In terms of performance testing, FYI I am getting 50% gains compared to DRF. Which is significant and would be great to have in prod...!
The text was updated successfully, but these errors were encountered: