Hi I have on my html file this, tags
and tagInfos
are both queryset´s of Django, that 2 for´s are only to show wich one belongs to the other:
<form action="/chart/chart/" method="get">
{% if tags.count > 0 %}
{% for tag in tags %}
{% for tagInfo in tagInfos %}
{% if tag.taginfo_idtaginfo1_id == tagInfo.idtaginfo %}
<!--
<div>
<h3><a href = "/tags/get/{{ tag.idtag }}/"> {{ tagInfo.nome}} </a></h3>
Datasource: {{ tag.datasource_idestacao_meteo }}
</div>
-->
<p>
<input type="checkbox" name="checks[]" value="{{ tag.idtag }}" />
<a href = "/tags/get/{{ tag.idtag }}/"> {{ tagInfo.nome}} </a>
Datasource: {{ tag.datasource_idestacao_meteo }}
</p>
{% endif %}
{% endfor %}
{% endfor %}
<!--To submit the chart creation-->
{% csrf_token %}
<button type="submit" class="btn btn-primary">Submit creation</button>
{% else %}
<p>None TAG to select.</p>
{% endif %}
</form>
So and on my view i try to do that:
def chart(request):
if 'checks' in request.GET and request.GET['checks']:
chosen = request.GET.getlist('checks')
return render_to_response('Chart/chart.html',
{
'chosen' : chosen,
}
)
else:
return render_to_response('Chart/chart.html',
{
}
)
But don´t show any of the selected checkboxes on the other html, I´m using {{ chosen }}
to show.
Any ideas of what I´m doing wrong?
Aucun commentaire:
Enregistrer un commentaire