writing your first Django app - part 4, radio button doesn't show

Hi - I thought I was carefully following the tutorial, but when I get to part 4, My browser just doesn’t show the radio button
I have three question in the database.

<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vote here</title>

    <form action="{% url 'polls:vote' question.id %}" method="post">
        {% csrf_token %}
            <legend><h1>{{ question.question_text }}</h1></legend>

            {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
            {% for choice in question.choice_set.all %}
                <input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}">
                <label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br>
            {% endfor %}
        <input type="submit" value="Vote">
from django.shortcuts import get_object_or_404, render
from django.http import HttpResponse, HttpResponseRedirect
from .models import Question
from django.http import Http404
from django.core.mail import send_mail
from django.template import loader
from django.urls import reverse
from .models import Choice, Question
# Create your views here.

def index(request):
    # Use this to send an email:
    # html_message = loader.render_to_string(
    #         'polls/email.html',
    #         {
    #             'user_name': 'fred',
    #             'subject':  'Thank you from',
    #         }
    #         )   
    # send_mail('Subject is here..','Here is the message','noreply@gmail.com',['russelsher@live.com'],fail_silently=True,html_message=html_message) 
    # print('Sent')
    latest_question_list = Question.objects.order_by('-pub_date')[:5]
    context = {'latest_question_list': latest_question_list}
    return render(request, 'polls/index.html', context)

def detail(request, question_id):
        question = Question.objects.get(pk=question_id)
    except Question.DoesNotExist:
        raise Http404("Question does not exist")
    return render(request, 'polls/detail.html', {'question': question})

def results(request, question_id):
    response = "You're looking at the results of question %s."
    return HttpResponse(response % question_id)

def vote(request, question_id):
    question = get_object_or_404(Question, pk=question_id)
        selected_choice = question.choice_set.get(pk=request.POST['choice'])
    except (KeyError, Choice.DoesNotExist):
        # Redisplay the question voting form.
        return render(request, 'polls/detail.html', {
            'question': question,
            'error_message': "You didn't select a choice.",
        selected_choice.votes += 1
        # Always return an HttpResponseRedirect after successfully dealing
        # with POST data. This prevents data from being posted twice if a
        # user hits the Back button.
        return HttpResponseRedirect(reverse('polls:results', args=(question.id,)))

You say you have three questions - do you have choices for each of those questions? (Or, at least, do you have choices for the question you’re trying to look at?)

Hi - thanks for the reply. Yes, my mistake was not to have the choices in the database to start with.
Thanks for that.

Hey RussellSher, Can you please help me to understand this, how did you solve this error? I have got the same error it says “Couldn’t find the radio button”

This doesn’t sound like the same problem. I suggest you open a new discussion topic for this issue, providing all the relevant details.