[Django]-How to Append the values of ValueQuryset to array?

5👍

ValueQuerySet yields dictionaries. Get items by indexing, instead of accessing attributes.

Replace following lines:

for b in state_filter:
    xdata.append(b.party)
    ydata.append(b.num)

with:

for d in age_filter:
    xdata.append(b['party'])
    ydata.append(b['party_count'])

Leave a comment