How do I show only one element present in the database according to the id in Django?

0

I am trying to show only the element saved in the database that corresponds to the other element. When I do this out of the script, it works perfectly, but when I play in the script it returns all the elements.

I'll put a part of the code:

Part of the script that does not work

<script>
function mostrarSel(){
x = "{% for questao in prova.questao_set.all %}{% for resposta in questao.resposta_set.all %}{{resposta.resposta}}{% endfor %}{% endfor %}";
alert(x);                      
}
</script>

Part that works out of script

{% for questao in prova.questao_set.all %}
    <div id="minhaDiv" style="display: none;">Resposta:
    {% for resposta in questao.resposta_set.all %}
      {{resposta.resposta}}
    {% endfor %}
    </div>
{% endfor %}

For those who want to see the full code: link

    
asked by anonymous 20.06.2018 / 16:19

0 answers