Django poll thing

This commit is contained in:
2020-03-14 10:52:39 -04:00
parent f09c3470c0
commit 8bfdafab61
16 changed files with 230 additions and 114 deletions

View File

@@ -0,0 +1,12 @@
<h1>{{ question.question_text }}</h1>
{% if error_message %}<p><strong>{{ error_mmessage }}</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>

View File

@@ -0,0 +1,9 @@
{% 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 %}

View File

@@ -0,0 +1,9 @@
<h1>{{ question.question_text }}</h1>
<ul>
{% for choice in question.choice_set.all %}
<li>{{ choice.choice_text }} -- {{ choice.votes }} vote{{ choice.votes|pluralize }}</li>
{% endfor %}
</ul>
<a href="{% url "polls:detail" question.id %}">Vote again?</a>