Passing list of values to django view via jQuery ajax call

前端 未结 5 709
一个人的身影
一个人的身影 2020-12-01 09:38

I\'m trying to pass a list of numeric values (ids) from one web page to another with jQuery ajax call. I can\'t figure out how to pass and read all the values in the list. I

5条回答
  •  情深已故
    2020-12-01 10:15

    This part is your problem:

    ourid = request.POST.get('terid', False)
    ingredients = Ingredience.objects.filter(food__id__in=ourid)
    

    You need to deserialize the JSON string.

    import json
    ourid = json.loads(request.POST.get('terid'))
    

提交回复
热议问题