2021年1月4日星期一

Fetch specific column in Django using JsonResponse

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 in my script?

I tried response.datas.paid_by but it returns undefined

Views.py

def sample():      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");    }  
https://stackoverflow.com/questions/65572274/fetch-specific-column-in-django-using-jsonresponse January 05, 2021 at 10:06AM

没有评论:

发表评论