1👍
It is advisable send json data
in request.session
and send query data
in view context. So it would be easy to apply django filters:
views.py
contract_posts = serializers.serialize('json', Contracts.objects.all())
c_p = json.loads(contract_posts)
request.session['contract_posts'] = c_p
context = {'contract_posts': contract_posts}
return render(request, 'customer2.html', context)
template
{% for contract in contract_posts %}
<tr>
<td>{{ contract.contract }}</td>
<td>{{ contract.name }}</td>
<td>{{ contract.debt }}</td>
<td>{{ contract.created_at|date:"d m Y"}}
</tr>
{% endfor %}
Source:stackexchange.com