Update serializers.md

Corrected class name in example
This commit is contained in:
Girik Bajaj 2023-09-10 13:41:27 +05:30
parent 4bbfa8d455
commit f1fee7a4cc

View File

@ -382,7 +382,7 @@ For example, suppose we wanted to ensure that `User` instances and `Profile` ins
This manager class now more nicely encapsulates that user instances and profile instances are always created at the same time. Our `.create()` method on the serializer class can now be re-written to use the new manager method. This manager class now more nicely encapsulates that user instances and profile instances are always created at the same time. Our `.create()` method on the serializer class can now be re-written to use the new manager method.
def create(self, validated_data): def create(self, validated_data):
return User.objects.create( return UserManager.objects.create(
username=validated_data['username'], username=validated_data['username'],
email=validated_data['email'], email=validated_data['email'],
is_premium_member=validated_data['profile']['is_premium_member'], is_premium_member=validated_data['profile']['is_premium_member'],