Re: How can i pass an extra data in form of dictionary to my serializer

2017-08-09 Thread DongHwan Lee
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

Re: How can i pass an extra data in form of dictionary to my serializer

2017-08-09 Thread DongHwan Lee
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'] =

Creating a batch of products with relationship

2017-08-09 Thread Charly Palencia
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