Here, 'arr' is a list passed from a previous view. The values(string type) of this list along with the check boxes are successfully being displayed.
<form action="{% url 'prec' %}" method="post">
{% for link in arr %}
<input type="checkbox" name="checks[]" value="{{link}}" />{{link}}<br>
{% endfor %}
<input type="submit" value="Submit">
</form>
In views function, I create a list of the fields/boxes checked by the user. (views.py):
from django.shortcuts import render
def prec(request):
if request.method == 'POST':
var = request.POST.getlist('checks[]')
return render(request, 'Link5_prec.html', {'variables':var})
Then, in another template, I want to display the values checked by the user(along with the index of that checkbox like [0,2,3]). But nothing is being displayed. (Link5_prec.html):
{% for v in variables %}
<h1>{{v}}</h1>
{% endfor %}
Also, if possible, in the first template, I want to make a checkbox of all the elements in the 'arr' list except the last element.