1👍
✅
Refactored the create method of the serializer and it now works
def create(self, validated_data):
request = self.context['request']
r_data = self.context['request'].FILES
post = Post.objects.create(**validated_data)
if 'image' in r_data:
post_image = PostImage.objects.create(image=r_data['image'])
post.image.add(post_image)
else:
pass
return post
Source:stackexchange.com