From df4ed21717f0e3dda6999725cc76ff0f310d6e0c Mon Sep 17 00:00:00 2001 From: Mohammad Shahrukh Date: Mon, 23 Apr 2018 16:57:07 +0530 Subject: [PATCH] Update serializers.md The class UserSerializer shows that the User model has a foreign key of a profile. Whereas when creating an object of a profile in the code it was written as Profile.objects.create(user=user, **profile_data) which means profile has a foreign key of users. --- docs/api-guide/serializers.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api-guide/serializers.md b/docs/api-guide/serializers.md index 07921f2d9..9755e3127 100644 --- a/docs/api-guide/serializers.md +++ b/docs/api-guide/serializers.md @@ -312,8 +312,8 @@ The following example demonstrates how you might handle creating a user with a n def create(self, validated_data): profile_data = validated_data.pop('profile') - user = User.objects.create(**validated_data) - Profile.objects.create(user=user, **profile_data) + profile = Profile.objects.create(**profile_data) + user = User.objects.create(profile=profile, **validated_data) return user #### Writing `.update()` methods for nested representations