title: How can i retrieve context from for loop in views django and send it to template
body: <p>I need to do one page with topic and all entries about this topic. And for each entries I need all comments shown up below each entry. Comments should be for exact entry. Cant find it solution and decided ask. Thank you.</p>
  <p><strong>models.py</strong></p>
  <pre><code> --snip--
      class Comment(models.Model):
          date_added = models.DateTimeField(auto_now_add=True)
          text = models.TextField()
          owner = models.ForeignKey(User, on_delete=models.CASCADE)
          entry = models.ForeignKey(Entry, on_delete=models.CASCADE)
  
      def __str__(self):
          return f&quot;{self.text[:50]}...&quot;
  </code></pre>
  <p><strong>views.py</strong></p>
  <pre><code>--snip--
      def topic(request, topic_id):
          topic = Topic.objects.get(id=topic_id)
          entries = topic.entry_set.all()
          comments = []
          for entry in entries:
              c = entry.comment_set.all()
              comments.append(c)
          context = {'topic': topic, 'entries': entries,
                     'comments': comments}
          return render(request, 'learning_logs/topic.html'
                        ,context)
  </code></pre>
  <p><strong>topic.html</strong></p>
  <pre><code>{% extends 'learning_logs/base.html' %}
  {% block content %}
      &lt;p&gt;{{ topic.title }}&lt;/p&gt;
      &lt;p&gt;{{ topic.description }}&lt;/p&gt;&lt;br&gt;
      &lt;p&gt;Entries:&lt;/p&gt;&lt;br&gt;
      &lt;ul&gt;
          {% for entry in entries %}
              &lt;li&gt;{{ entry.text }}&lt;/li&gt;
              &lt;ul&gt;
                  &lt;p&gt;Comments:&lt;/p&gt;
                  {% for comment in comments %}
                      &lt;li&gt;{{ comment.text }}&lt;/li&gt;
                  {% endfor %}&lt;br&gt;
              &lt;/ul&gt;
          {% empty %}
              &lt;li&gt;Not entries&lt;/li&gt;
          {% endfor %}
      &lt;/ul&gt;
  
  {% endblock content %}
  </code></pre>