How can I convert a Django QuerySet into a list of dicts? I haven\'t found an answer to this so I\'m wondering if I\'m missing some sort of common helper function that every
You could define a function using model_to_dict as follows:
def queryset_to_dict(qs,fields=None, exclude=None):
my_array=[]
for x in qs:
my_array.append(model_to_dict(x,fields=fields,exclude=exclude))
return my_array