[Python] How can I access a dictionary element in a Django template?

Discussão em 'Python' iniciado por Stack, Novembro 25, 2025.

  1. Stack

    Stack Membro Participativo

    I would like to print out the number of votes that each choice got. I have this code in a template:

    {% for choice in choices %}
    {{choice.choice}} - {{votes[choice.id]}} <br />
    {% endfor %}


    votes is just a dictionary while choices is a model object.

    It raises an exception with this message:

    "Could not parse the remainder"

    Continue reading...

Compartilhe esta Página