The "polls_choice" table in database file db.sqlite3 has no records, so no 
radio buttons show up.
I manually added 2 records to the "polls_choice" table, then I have the 
radio buttons showed up.


On Tuesday, February 7, 2017 at 6:17:58 PM UTC+8, ludovic coues wrote:
>
> Have you added some choices to the "What's up?" question ? 
>
> What you see is that question.choice_set.all is empty. 
> The following snippet will give you some output: 
>
> {% 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 /> 
> {% empty %} 
>     <p>Sorry, no available choices.</p> 
> {% endfor %} 
>
> 2017-02-07 10:12 GMT+01:00 Brady Lee <jack...@gmail.com <javascript:>>: 
> > Same issue here, no radio buttons show up. 
> > 
> > ubuntu 16.04.1 LTS 
> > python 3.5.2 
> > django 1.10.5 
> > 
> > I've tried  {{ question|pprint }} and {{ question.choice_set.all|pprint 
> }} 
> > for debugging, got: 
> > 
> > <Question: What's up?> <QuerySet []> 
> > 
> > Now trying to figure out where the problem is. 
> > 
> > 
> > On Thursday, October 20, 2016 at 11:52:59 PM UTC+8, Othniel Ayinzat 
> wrote: 
> >> 
> >> Hi guys, 
> >>  I have been following the django tutorials up to part 4 on the polls 
> >> application. My details template only displays the vote submit button 
> but 
> >> the radio buttons for making choices won't show. I have been battling 
> with 
> >> this for some hours now and i need help or some pointers. Thanks. Below 
> are 
> >> the code snippets for the polls app. 
> >> 
> >> polls/templates/polls/detail.html 
> >> ----------------------------------------------- 
> >> <h1>{{ question.question_text }}</h1> 
> >> {% if error_message %}<p><strong>{{ error_message }}</strong></p>{% 
> endif 
> >> %} 
> >> <form action="{% url 'polls:vote' question.id %}" method="post"> 
> >> {% csrf_token %} 
> >> {% 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" /> 
> >> </form> 
> >> 
> >> polls/templates/polls/index.html 
> >> ----------------------------------------------- 
> >> 
> >> {% if latest_question_list %} 
> >> <ul> 
> >> {% for question in latest_question_list %} 
> >> <li><a href="{% url 'polls:detail' question.id %}">{{ 
> >> question.question_text }}</a></li> 
> >> {% endfor %} 
> >> </ul> 
> >> {% else %} 
> >> <p>No polls are available.</p> 
> >> {% endif %} 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to django-users...@googlegroups.com <javascript:>. 
> > To post to this group, send email to django...@googlegroups.com 
> <javascript:>. 
> > Visit this group at https://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/8a5fe550-62bf-42e5-8dfa-0b3fc8d5d4cf%40googlegroups.com.
>  
>
> > 
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
>
> Cordialement, Coues Ludovic 
> +336 148 743 42 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5ab09a09-69a6-41f5-85eb-791d514b6350%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to