When making a post request in Django I get the error that 'create()' has not been implemented when I did indeed implement it in my serializer file
from rest_framework import serializers
from people.models import People
class PeopleSerializer(serializers.Serializer):
pk = serializers.IntegerField(read_only=True)
name = serializers.CharField(max_length=200)
favoriteCity = serializers.CharField(max_length=200)
def create(self, validated_data):
return People.objects.create(**validated_data)
def update(self, instance, validated_data):
instance.name = validated_data.get('name', instance.name)
instance.favoriteCity = validated_data.get(
'favoriteCity',instance.favoriteCity)
instance.save()
return instance()
Clearly the create method has been implemented and I don't understand why i'm getting a NotImplementedError