5👍
✅
Pass data
when instantiating your serializer, not context
.
def post(self, request, *args, **kwargs):
serializer = ResourceListSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
serializer.save(creator=request.user)
You only need context
to pass extra context. Unless you have custom code in your serializer that accesses self.context
, you don’t need it.
Source:stackexchange.com