[Answer]-Django is not printing _id to console

1👍

✅

Your problem is most likely a typo:

{% extends 'base.html' %}

{% block content %}
<div class='row'>

    {% for question in questions %}    
        {{ question }}<br/>
        <form method='POST' action=''>{% csrf_token %}
        <input type='hidden' **vlaue**='{{ question.id }}' name='question_id'/>
            {% for ans in question.answer_set.all %}
            <input type='radio' value='{{ ans }}' name='answer'>{{ ans }} <br/>
            {% endfor %}
            <input type='submit' value='Submit'>
        </form>
    {% endfor %}

</div>

{% endblock %}

It should be:

{% extends 'base.html' %}

{% block content %}
<div class='row'>

    {% for question in questions %}    
        {{ question }}<br/>
        <form method='POST' action=''>{% csrf_token %}
        <input type='hidden' value='{{ question.id }}' name='question_id'/>
            {% for ans in question.answer_set.all %}
            <input type='radio' value='{{ ans }}' name='answer'>{{ ans }} <br/>
            {% endfor %}
            <input type='submit' value='Submit'>
        </form>
    {% endfor %}

</div>

{% endblock %}

Leave a comment