title: Get nth iteration in Django template
body: <p>I am trying to get the first or nth iteration only in a Django template.
  Usually I can iterate through using,</p>
  
  <pre><code>{% for item in pModel %}
      {{ item.post }}
  {% endfor %}
  </code></pre>
  
  <p>I need the first iteration but would also like to know how to get the n-th iteration,</p>
  
  <p>{{ pModel.0.post }}` displays nothing and gives no error.</p>
  
  <p>I don't want to iterate through every object in pModel. </p>
  
  <p>I have tried all combinations i.e. </p>
  
  <pre><code>{{ pModel[0][post] }}
  {{ pModel.0.[post] }}
  {{ pModel[0].post }}
  {{ pModel[0][post] }}
  {{ pModel.[0][post] }}
  {{ pModel.[0].[post] }} etc.
  </code></pre>
  
  <p>The pModel comes from this view,</p>
  
  <pre><code>def profile(request, id):
      pk = id
      name = User.objects.all().filter(id=pk)
      pModel = reversed(PostModel.objects.all().filter(author = name[0]))
      # user_instance = User.objects.all().filter(username = request.user)
      return render(request, 'profile.html', {'pModel': pModel, 'current_time': timezone.now()})
  </code></pre>
  
  <p>The following display nothing,</p>
  
  <pre><code>&lt;strong&gt;{{ pModel.first.post }}&lt;/strong&gt;
  </code></pre>
  
  <p>In the same template I use the pModel which displays correctly so i know that the pModel is working. The complete template,</p>
  
  <pre><code>{% extends 'index.html' %} {% block homepage %}
  &lt;div class="post"&gt;
    {% if pModel %}
      &lt;h3&gt;Profile for &lt;strong&gt;{{ pModel.first.post }}&lt;/strong&gt;&lt;/h3&gt;
    &lt;p&gt;Last logged in: {{user.last_login|timesince:current_time}} ago on {{ user.last_login }}&lt;/p&gt;
    &lt;p&gt;Joined {{user.date_joined|timesince:current_time}} ago on {{ user.date_joined }}&lt;/p&gt;
    {% endif %}
      {% if pModel %}
      &lt;div class="table-responsive"&gt;
        &lt;table class='table table-striped table-hover'&gt;
          &lt;thead&gt;
            &lt;tr&gt;
              &lt;th&gt;{{user.username}}'s posts&lt;/th&gt;
              &lt;th&gt;Topic&lt;/th&gt;
              &lt;th&gt;Topic Started By&lt;/th&gt;
              &lt;th&gt;Last Active&lt;/th&gt;
              &lt;th class="table-cell-center"&gt;Views&lt;/th&gt;
            &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
            {% for item in pModel %}
            &lt;tr&gt;
              &lt;td&gt;&lt;a href="{% url 'thread' item.topic_id %}"&gt;{{ item.post }} uuu {{ pModel.0}}&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;{{ item.topic.topic }}&lt;/td&gt;
              &lt;!-- item.topicid.authorid_id --&gt;
              &lt;td&gt;&lt;a href="{% url 'profile' user.id %}"&gt;{{ item.topic.topicAuthor }}&lt;/a&gt;&lt;/td&gt;
              &lt;td class="icon-nowrap"&gt;{{ item.pub_date|timesince:current_time}}&lt;/td&gt;
              &lt;td class="table-cell-center"&gt;{{ item.topic.views }}&lt;/td&gt;
            &lt;/tr&gt;
            {% endfor %}
          &lt;/tbody&gt;
        &lt;/table&gt;
      &lt;/div&gt;
      {% endif %}
  &lt;/div&gt;
  {% endblock %}
  </code></pre>