I'm new to using the DRF so I apologize if this is a trivial question but I've had no luck finding an answer thus far.
I'm using DRF along with Angularjs to create a single page application. When I make posts to my API I get this error to create a new Task
object: task_id: [This field is required.]
task_id
is my primary key on this object. How can I make it so that it gets incremented automatically like it would on a Django Model Form?
class TaskSerializer(serializers.ModelSerializer):
class Meta:
model = Task
fields = ('route', 'date', 'task_id', )
class AddTask(generics.CreateAPIView):
serializer_class = TaskSerializer
def get(self, request, format=None):
response = {}
response['form'] = TaskForm().as_p()
return Response(response)
Are you using
task_id
in your application page? If not, then remove it from the serializer and DRF will automatically take care of this for you.Something like this: