Django Rest Framework Serializer POST data not receiving arrays

Viewed 1006

I'm using the DRF test api for testing my serializers, for instance I made my data like this:

image_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../media/', 'product_images/', 'myimage.png')
    with open(image_path) as image:
        encoded_image = base64.b64decode(image.read())
        data = {
            u'small_name': u'Product Test Case Small Name',
            u'large_name': u'Product Test Case Large Name',
            u'description': u'Product Test Case Description',
            u'images': [
                {u'image': encoded_image}
            ],
            u'variants': [
                {u'value': u'123456789'}
            ]
        }
response = self.client.post(url, data, 'multipart')

However when I receive the data on the respective serializer the variants array and the images array are empty.

What could be the issue here?

4 Answers
Related