Closed pmg103 closed 4 years ago
As an alternative to
serialization_spec = [ 'sessions' ]
It ought to be possible to provide a method get_serialization_spec(self), following the pattern from DRF, so that the spec can depend on values at runtime (most likely the request user):
get_serialization_spec(self)
def get_serialization_spec(self) return [ {'sessions': Filtered(Q(created_by=self.request.user), [ 'id' ]} ]
Note that for this to work in SerializationSpecPlugins, request_user would have to be assigned before calling get_serialization_spec()
SerializationSpecPlugin
request_user
get_serialization_spec()
As an alternative to
It ought to be possible to provide a method
get_serialization_spec(self)
, following the pattern from DRF, so that the spec can depend on values at runtime (most likely the request user):Note that for this to work in
SerializationSpecPlugin
s,request_user
would have to be assigned before callingget_serialization_spec()