Yes, I added this in settings.py
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': [
# 'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.BasicAuthentication',
]
}
In views.py
@api_view(['POST'])
def apipost(request):
serializer = cvserializer(data=request.data)
if serializer.is_valid():
serializer.save()
else:
print('serializer.errors', serializer.errors)
return Response(serializer.data)
Now, the csrf error is gone, but the serializer.is_valid() is not true,
I checked the serializer.errors() =>
{'classes': [ErrorDetail(string='This field is required.', code='required')], 'date_d': [ErrorDetail(string='This field is required.', code='required')]}
how to solve this , thanks