title: how can I return all object's id and placed in my_result objects? [django]
body: <p>when I submit this form always returns to me the value of id 1 only and when I tried to replace another value I wrote 2 has returned to me this value indeed. then I understood that this loop process doesn't work and I knew that because of (return). so, I need to know how can I return all object's id and placed in my_result objects</p>
  
  <p>views.py</p>
  
  <pre><code>from django.shortcuts import render
  from .models import Section, Question, Result
  from django.http import HttpResponseNotFound
  
  
  def index(request):
      text = "this is from views of exam app!"
      return render(request, 'exam/index.html', {'text': text})
  
  
  def section_list(request):
      try:
          sections = Section.objects.all()
      except:
          return HttpResponseNotFound("Error")
      return render(request, 'exam/section.html', {'portals': sections})
  
  
  def my_question(request, q_id):
      sections = Section.objects.get(id=q_id)
      template_name = 'exam/question.html'
  
      try:
          answer = request.POST['answer']
          for result in Result.objects.all():
              result_id = result.result_question_id
              my_result = Result.objects.filter(id=result_id)
              return render(request, template_name, {'repr': repr(my_result)})
      except:
          return render(request, template_name, {'sections': sections, 'error_message': 'You have to select one of the following answer'})
      return render(request, template_name, {'sections': sections})
  </code></pre>
  
  <p>urls.py</p>
  
  <pre><code>from . import views
  from django.urls import path
  from django.conf.urls import url
  
  app_name = "exam"
  
  urlpatterns = [
      # /index/
      path('', views.index, name="index"),
      # /index/section/
      path('portal/', views.section_list, name="portal"),
      # /index/question/10/
      path(r'question/&lt;int:q_id&gt;/', views.my_question, name="question"),
  ]
  </code></pre>
  
  <p>models.py</p>
  
  <pre><code>from django.db import models
  
  
  class Section(models.Model):
      portal = models.CharField(max_length=100)
  
      def __str__(self):
          return self.portal
  
  
  class Question(models.Model):
      section = models.ForeignKey(Section, on_delete=models.CASCADE)
      question = models.CharField(max_length=100)
      choice = models.BooleanField(default=False)
      ans1 = models.CharField(max_length=100)
      ans2 = models.CharField(max_length=100)
      ans3 = models.CharField(max_length=100)
      ans4 = models.CharField(max_length=100)
  
      def __str__(self):
          return self.question
  
  
  class Result(models.Model):
      result_question = models.ForeignKey(Question, on_delete=models.CASCADE)
      result = models.CharField(max_length=100)
  
      def __str__(self):
          return self.result
  </code></pre>
  
  <p>question.html</p>
  
  <pre><code>{% extends 'base.html' %}
  
  {% block title %} Question Page {% endblock %}
  
  {% block body %}
  {% if error_message %}
      &lt;div class="notes"&gt;
          &lt;div class="container"&gt;
              &lt;div class="alert alert-info"&gt;
                  &lt;strong&gt;Info!&lt;/strong&gt; {{ error_message }}
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  {% endif %}
  
      &lt;div class="questions"&gt;
          &lt;div class="container"&gt;
              {% for section in sections.question_set.all %}
                  &lt;h2&gt;{{ section.question }}&lt;/h2&gt;
                  &lt;form method="post"&gt;
                  {% csrf_token %}
                      &lt;div class="answer"&gt;
                          &lt;input type="radio" name="answer" id="{{ section.ans1 }}" value="{{ section.ans1 }}"&gt;
                          &lt;label for="{{ section.ans1 }}"&gt;{{ section.ans1 }}&lt;/label&gt;
                          {% if false_answer %}
                              &lt;span class="false-message"&gt;{{ false_answer }}&lt;/span&gt;
                          {% elif true_answer %}
                              &lt;span class="true-message"&gt;{{ true_answer }}&lt;/span&gt;
                          {% endif %}
                      &lt;/div&gt;
  
                      &lt;div class="answer"&gt;
                          &lt;input type="radio" name="answer" id="{{ section.ans2 }}" value="{{ section.ans2 }}"&gt;
                          &lt;label for="{{ section.ans2 }}"&gt;{{ section.ans2 }}&lt;/label&gt;
                          {% if false_answer %}
                              &lt;span class="false-message"&gt;{{ false_answer }}&lt;/span&gt;
                          {% elif true_answer %}
                              &lt;span class="true-message"&gt;{{ true_answer }}&lt;/span&gt;
                          {% endif %}
                      &lt;/div&gt;
  
                      &lt;div class="answer"&gt;
                          &lt;input type="radio" name="answer" id="{{ section.ans3 }}" value="{{ section.ans3 }}"&gt;
                          &lt;label for="{{ section.ans3 }}"&gt;{{ section.ans3 }}&lt;/label&gt;
                          {% if false_answer %}
                              &lt;span class="false-message"&gt;{{ false_answer }}&lt;/span&gt;
                          {% elif true_answer %}
                              &lt;span class="true-message"&gt;{{ true_answer }}&lt;/span&gt;
                          {% endif %}
                      &lt;/div&gt;
  
                      &lt;div class="answer"&gt;
                          &lt;input type="radio" name="answer" id="{{ section.ans4 }}" value="{{ section.ans4 }}"&gt;
                          &lt;label for="{{ section.ans4 }}"&gt;{{ section.ans4 }}&lt;/label&gt;
                          {% if false_answer %}
                              &lt;span class="false-message"&gt;{{ false_answer }}&lt;/span&gt;
                          {% elif true_answer %}
                              &lt;span class="true-message"&gt;{{ true_answer }}&lt;/span&gt;
                          {% endif %}
                      &lt;/div&gt;
                      &lt;button class="btn btn-success"&gt;Next&lt;/button&gt;
  
  
                  {{ section.id }}
                  {{ result.result_question_id }}
                  &lt;/form&gt;
  
              {% endfor %}
  
              {% if repr %}
                  {{ repr }}
              {% endif %}
  
          &lt;/div&gt;
      &lt;/div&gt;
  
  {% endblock %}
  </code></pre>