-1

enter image description here

I want to convert this queryset to json.

enter image description here

json.dumps() does not work.

enter image description here

serialize does not work.

enter image description here

json.dumps() + list() does not work

how can I convert querset to json? maybe the reason these conversions are not work is in here. enter image description here

I know that Models.objects.all() or Models.objects.all().only() return queryset, Models.objects.all().values() returns list of dict.

I want to add a new key-value set to the first queryset, So I use Models.objects.all().values()

but when I add a new key-value set, I think, the datatype is twisted. so now the datatype of 'questionRequeestList' is neither 'List' nor 'Queryset' at converting to json.

how can I convert this value to json? or how can I add new queryset to another queryset dict?

1 Answers1

-1

First, using Django's query operations, such as the filter () method, returns a query set object. This is an object that can't use JSON. Dumps () directly, because the parameter needed to change the method is a dictionary, not a query set object. Here is a suggestion: use a loop to take out every element in the query set, and then use the modified method to convert it to JSON data.

Example: a = list for i in questionRequeestList: a= a.append(json.dumps(i))