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.
This commit is contained in:
Mohammad Shahrukh 2018-04-23 16:57:07 +05:30 committed by GitHub
parent 7d64b7016d
commit df4ed21717
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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