Django-rest-framework: Foreignkey Instance Is Not Passed To Validated_data
I'm trying to create an instance overriding create method and passing the ForeignKey instance in the data, but that field is not included in validated_data passed to create method.
Solution 1:
You can pass it as additional argument of save method:
serializer = UserProfileSerializer(data=request.data)
if serializer.is_valid():
user_profile = serializer.save(user=user)
From the docs:
Any additional keyword arguments will be included in the validated_data argument when .create() or .update() are called.
Post a Comment for "Django-rest-framework: Foreignkey Instance Is Not Passed To Validated_data"