SQL Lite total row count fetching not working with Django Models
Try this
kpi_data_cnt=TKPI_DETAIL_RECORD.objects.filter(MONTH_KEY = "202005"').count()
kpi_data_cnt = TKPI_DETAIL_RECORD.objects.raw('SELECT COUNT(*) FROM first_app_TKPI_DETAIL_RECORD where MONTH_KEY = "202005"')
print(kpi_data_cnt)
I want to populate the total row count from the table first_app_TKPI_DETAIL_RECORD and store in the variable "kpi_data_cnt". But it is not working using the above code. I also put a display in my code to check the value of the variable "kpi_data_cnt". There is in the display, it is showing the total select query instead of providing me the row counts.