Я пытаюсь вставить записи через APIView, но он возвращает ошибку типа Ожидается, что Response
, HttpResponse
или HttpStreamingResponse
будет возвращено из представления, но получено <class 'NoneType'>
это views.py
class TrackList(APIView):
def post(self,request, *args, **kwargs):
employee = Employee.objects.filter(username=kwargs.get('username'), password=kwargs.get('password'))
if employee.exists():
serializer_class = TrackSerializer(data = request.data)
try:
if serializer_class.is_valid():
serializer_class.save(employee=employee[0])
return response.Response(serializer_class.data, status = status.HTTP_201_CREATED)
except Exception as e:
print(e)
return response.Response(serializer_class.errors, status = status.HTTP_404_NOT_FOUND)
, пожалуйста, помогите мне, как это можно исправить?