[Answer]-Creating a value in django template form

1👍

Ah, I figured it out;

<form action="" method="post" enctype="multipart/form-data">{% csrf_token %}
<input type="hidden" name="engine_ids" value="{% for engine in engines %}{{engine.id}},{% endfor %}"/>
<input type="submit" value="Export engines" name="export"/>
</form>
👤A G

0👍

import json
...
return render(request, 'template', {'engine_id_list': json.dumps([e.id for e in Engine.objects.filter(thefilter)])}

Leave a comment