我需要没有javascript的django模板中的代码来显示基于投票数的相同图像的长度。我目前的代码是:
<div id="Results">
<h1>{{question.question_text}}</h1>
{% for choice in question.choice_set.all %}
<div id="votes">
<img style="border-radius: 2px; border-width: 2px; border-style: none solid solid none; border-color: darkblue;" src='{{choice.image2.url}}'
/>
<div style=" float: right; width: 88%;">
<b>{{choice.choice_text}}</b>
{{choice.votes}} vote{{choice.votes|pluralize}}
</div>
</div>
{% endfor %}
</ul>
<p id="info">Your Vote Has Been Stored!!</p>
<br>
</div>
帮我用算法生成代码:
这是我的models.py
来自django.db导入模型
# Create your models here.
class Question(models.Model):
question_text = models.CharField(max_length= 100)
pub_date = models.DateTimeField('Date Is Published')
image = models.ImageField(upload_to="Question_Image", blank=True)
def __str__(self):
return self.question_text
class Choice(models.Model):
choice_text = models.CharField(max_length= 200)
votes = models.IntegerField(default= 0)
image2 = models.ImageField(upload_to="Question_Image2", blank=True)
question = models.ForeignKey(Question, on_delete= models.CASCADE)
def __str__(self):
return self.choice_text