Why is django using again shows a field of the database?

I Use Postgresql.
models.py
class Question(models.Model):
 question_text = models.CharField(max_length=200)
 pub_date = models.DateTimeField('date published')
 def __str__(self):
 return self.question_text

class Choice(models.Model):
 question = models.ForeignKey(Question, on_delete=models.CASCADE)
 choice_text = models.CharField(max_length=200)
 votes = models.IntegerField(default=0)
 def __str__(self):
 return self.choice_text

index.html
the <h3>{{ question.question_text }}</h3>
{% if error_message %} <p><strong>{{ error_message }}</strong></p>{% endif %}
<form action="/vote/" method="post">
 <div class="radio">
{% csrf_token %}
 {% for choice in choice_list %}
 <input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}">
 <label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br>
{% endfor %}<br>
<input type="submit" class="btn btn-default" value="Vote">
</div>
</form>

views.py
def main(request):
 all_info = Info.objects.all()
 question = Question.objects.filter(pk=1)
 choice = Choice.objects.all()
 return render(request,'main.html',{'all_info':all_info,'question':question,'choice_list': choice})

In index.html field <h3>{{ question.question_text }}</h3> is displayed through again after you refresh the page. May appear after 2 or 3 times after the update. What can here be wrong?
July 9th 19 at 13:14
1 answer
July 9th 19 at 13:16
Solution
In the vyuha is
question = Question.objects.filter(pk=1)
replace it
question = Question.objects.get(pk=1)
When you do .filter(..) - returns you the list you are trying to display in the template. And when .get(...) - for a specific object.
Passed by, and why it appears? Not has nothing at all to be. - shani commented on July 9th 19 at 13:19
it is not lawful for - Nathan_Gaylord commented on July 9th 19 at 13:22
When adding a get() it turns out that's the problem NoReverseMatch? - sylvia.Raynor commented on July 9th 19 at 13:25
On the LAN this error, but the server seems to be working. Not clear,of course, why. In General, thanks. - sylvia.Raynor commented on July 9th 19 at 13:28

Find more questions by tags Django