0

I have a problem on how can I filter specific column using Jsonresponse in html. I just want to filter specific column Paid_by. It is possible to filter in Jsonresponse just like this response.data.paid_by. Other option how to filter specific column in my views It would be great if anybody could figure out where I am doing something wrong. thank you so much in advance.

I tried response.datas.paid_by but it returns undefined

Views.py

def dictfetchall(cursor):
    desc = cursor.description
    return[
        dict(zip([col[0] for col in desc], row))
        for row in cursor.fetchall()
    ]

def sample():
    blank = ""
    with connection.cursor() as cursor:
         cursor.execute("SELECT * FROM app_person WHERE paid_by != %s GROUP BY paid_by, paid, category, category_status ORDER BY paid_by,paid", [blank])
         row = dictfetchall(cursor)
result = {'data':row}
return JsonResponse(result)

JsonResponse Success html

success: function(response){
    console.log(response.data) #fetch all data
    console.log(response.data.paid_by) #Undefined

    $("#rports").modal('show');
    $("#rports").val(null).trigger("change");
  }
BootCamp
  • 444
  • 4
  • 18

0 Answers0