1
I am trying to make a check to modify the bootstrap component according to the status id, but it returns me this error:
Could not parse the remainder: '[1]' from 'i[1]' in Django
The code snippet that gives error is the one that follows:
{%for i in cli %}
{% for x in i %}
<div class="col-lg-12">
<h5 class="list-group-item row">
<div class="col-lg-4">
{{ x.nome }} {{ x.sobrenome }}
</div>
<div class="col-lg-4">
{{ x.email }}
</div>
<div class="col-lg-4">
{% if {{ i.1 }} == 1 %}
<a href="/desativa_cliente/{{ x.cpf }}">
<span class = "glyphicon glyphicon-remove pull-right"></span>
</a>
{% elif {{ i.1 }} == 2 %}
<a href="/desativa_cliente/{{ x.cpf }}">
<span class = "glyphicon glyphicon-repeat pull-right"></span>
</a>
{% elif {{ i.1 }} == 2 %}
<a href="/desativa_cliente/{{ x.cpf }}">
<span class = "glyphicon glyphicon-repeat pull-right"></span>
</a>
{% endif %}
<a href="/clientes/edita_cliente/{{ x.cpf }}/">
<span class="glyphicon glyphicon-edit pull-right" style="margin-left:10px;"></span>
</a>
</div>
</h5>
</div>
{% endfor %}
{% endfor %}
What is the type of
i
? Inside a Django template,i.1
would be the same asi[1]
, but unlessi
is a list that doesn’t make much sense... Besides, within a{% ... %}
you can access variables directly, you don’t need [and as far as I know, you can’t] use{{ var }}
.– mgibsonbr