DRF:在GET中使用特定数据时出现KeyError

时间:2020-03-20 23:04:25

标签: django-models django-rest-framework

@api_view(['GET',]) @permission_classes([IsAuthenticated]) def Reservation_get(request): if request.method == 'GET': Date = request.data['date'] ress = reservation.objects.filter(date=Date) serializer = ReservationSerializer(ress, many=True) if ress.exists(): response = {'message': 'this/these date already chosen in restaurant', 'result': serializer.data} return Response(response) else: return Response(serializer.data) my views

my Error

   File "D:\#py\git projects\company Project\last\api\reservation\views.py", line 68, in Reservation_get
   Date = request.data['date']
   KeyError: 'date'
   [21/Mar/2020 03:29:19] "GET /reservation_get/ HTTP/1.1" 500 99859

我的GET适用于邮递员,但正常的网址显示错误

0 个答案:

没有答案