title: How to use Primary Key in Django context view to render on html in python for loop
body: <p>I have this method in my views followed by my html:</p>
  <pre class="lang-py prettyprint-override"><code>def index(request):
  
      context = {
          &quot;user&quot;: User.objects.get(id = request.session['user_id']),
          &quot;book&quot;: Book.objects.all(),
          &quot;review&quot;: Book.objects.get(pk=1).book_reviews.all()
      }
      return render(request, &quot;books_home.html&quot;, context)
  </code></pre>
  <pre class="lang-html prettyprint-override"><code>    {% for Book in book %}
              {{Book.contributor.id}}&lt;br&gt;
              Book Title: &lt;a href=&quot;{{Book.id}}&quot;&gt;{{Book.title}}&lt;/a&gt;&lt;br&gt;
              Author: {{Book.author.name}}&lt;br&gt;
              Contributor: &lt;a href=&quot;{{Book.contributor.id}}&quot;&gt;{{Book.contributor.first_name}} {{Book.contributor.last_name}}&lt;/a&gt;&lt;br&gt;
              {% for book_reviews in review %}
                  &lt;a href=&quot;{{User.id}}&quot;&gt;{{book_reviews.poster.first_name}} {{book_reviews.poster.last_name}}&lt;/a&gt; says: {{book_reviews.content}}&lt;br&gt;
                  Rating: {{book_reviews.rating}}&lt;br&gt;
                  Posted on: {{book_reviews.created_at}}&lt;br&gt;
              {% endfor %}
              {% if Book.contributor.id == request.session.user_id %} &lt;a href=&quot;reads/{{Book.id}}/delete&quot;&gt;Delete All&lt;/a&gt;{% endif %}
              &lt;hr&gt;
  </code></pre>
  <p>I'm having a problem with &quot;review&quot;: <code>Book.objects.get(pk=1).book_reviews.all()</code>, the <code>pk=1</code> is the problem. I don't know how to run through each pk so that each review is rendered, not just those with <code>pk=1</code>.</p>
  <p>models</p>
  <pre class="lang-py prettyprint-override"><code>class Author(models.Model):
      name = models.CharField(max_length=255)
      created_at = models.DateTimeField(auto_now_add = True)
      updated_at = models.DateTimeField(auto_now = True)
  
  class Book(models.Model):
      title = models.CharField(max_length=255)
      contributor = models.ForeignKey(User, related_name = &quot;book_added&quot;, 
      on_delete = models.CASCADE)
      author = models.ForeignKey(Author, related_name = &quot;book_written&quot;, 
      on_delete = models.CASCADE)
      created_at = models.DateTimeField(auto_now_add = True)
      updated_at = models.DateTimeField(auto_now = True)
  
  class Review(models.Model):
      content = models.CharField(max_length=255)
      rating = models.IntegerField()
      poster = models.ForeignKey(User, related_name=&quot;user_reviews&quot;, 
      on_delete=models.CASCADE)
      book = models.ForeignKey(Book, related_name=&quot;book_reviews&quot;, 
      on_delete=models.CASCADE)
      created_at = models.DateTimeField(auto_now_add = True)
      updated_at = models.DateTimeField(auto_now = True)
  </code></pre>