[Django]-TypeError: manager_method() argument after ** must be a mapping, not str

2๐Ÿ‘

โœ…

I think you misunderstood what you receive in the validated_data. validated_data is a mapping (dictionary), whose nested serializer keys are also dictionaries. What I think happened is that you were trying to create an object using the dictionary keys (strings), resulting in the error you received.

Try this:

A.objects.create(n=n, **a_data)

Documentation on this exact case can be found here:
https://www.django-rest-framework.org/api-guide/relations/#writable-nested-serializers

๐Ÿ‘คcakelover

Leave a comment