I use serialize to get data in view.
contract_posts = serializers.serialize('json', Contracts.objects.all())
Then I use json.loads get data, but I just get 1 by 1 case not all data from model.
contract_posts = json.load(contract_posts)[0]
print(contract_posts["fields"])
I want to get all data, I try to use for loop but it show error
'str' object has no attribute 'read'
My for loop :
for i in range(100):
contract_posts = json.load(contract_posts)[i]
print(contract_posts["fields"]["contract"])
I dont know how to get len json.load(contract_posts), so I use range 100 as an example number
Please help me all