If user_data is validated_data, you can simply add kwarg 'context' to pass
an extra data.
serializer = UserSerializer(data=user_data, context={'device_id': device_id
})
Inside UserSerializer, you can get device_id by
self.context['device_id']
Or you can use built-in method
def get_serializer_context(self):
"""
default return is
{
'request': self.request,
'format': self.format_kwarg,
'view': self
}
"""
context = super(YourViewSet, self).get_serializer_context()
# You can add what you want
context['device_id'] =
Hi guys,
i have an issue trying to create multiples products with rest framework
serializer
first i have a dictionary of products
[{'name': 'test1', 'product_type': product_type}]
i have a Product and ProductType classes, the product_type is an instance
of some product_type. so then i