Field 'id' expected a number but got

后端 未结 3 588
鱼传尺愫
鱼传尺愫 2021-01-25 17:04

i want to delete and edit notes in my django app, but i am struck on this error for long Error : \"TypeError at /delete/1/ Field \'id\' expected a number but got .

3条回答
  •  终归单人心
    2021-01-25 17:51

    Please see this answer if you were playing with API(Rest Framework of Django) I got this error and I solved it by changing True to False while serializing the object.

    @api_view(['GET'])
    def event_detail(request, pk):
        try:
            event = Event.objects.get(id=pk)
            # This is the line I have made changes True to False.
            serializer = EventSerializer(event, many=False)
            return Response(serializer.data)
        except:
            return render(request, "404_page.html")
    

提交回复
热议问题