[Fixed]-Django rest framework: 'create( )' NotImplementedError when making Http POST request

42👍

In your serializer class inherit from ModelSerializer instead of Serializer class since the later doesn’t call create() method implicitly.

class PeopleSerializer(serializers.ModelSerializer): 

The above change would do your job!

3👍

Please check your indentation, that ‘create’ function should be inside that Serializer class, as below example.

class StudentSerializer(serializers.Serializer):
    name = serializers.CharField(max_length=111)
    roll = serializers.IntegerField()
    city = serializers.CharField(max_length=722)

    def create(self,validated_data):
        return Student.objects.create(**validated_data)

-1👍

Check if the keys inside data exactly match model attributes when you try to create an object of a particular model using the model serializer

-1👍

Please check your indentation, that ‘create’ function should be within that Serializer class Hopefully it will work.

-1👍

from rest_framework import serializers
from .models import Student

class StudentSerializer(serializers.Serializer):
name=serializers.CharField(max_length=555)
def create(self,validated_data):
return Student.objects.create(**validated_data)enter image description here

Leave a comment