Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
templates/blog/list.html
{% extends "base.html" %}
{% block content %}
<div class="main">
<!-- Posts -->
<ul>
{% for post in posts.object_list %}
<div class="title">{{ post.title }}</div>
<ul>
<div class="time">{{ post.created }}</div>
<div class="body">{{ post.body|truncatewords:50 }}</div>
<div class="commentlink"><a href="{% url post post.pk %}">More</a></div>
</ul>
<br />
{% endfor %}
</ul>
<!-- Next/Prev page links -->
{% if posts.object_list and posts.paginator.num_pages > 1 %}
<div class="pagination" style="margin-top: 20px; margin-left: -20px; ">
<span class="step-links">
{% if posts.has_previous %}
<a href= "?page={{ posts.previous_page_number }}">newer entries &lt;&lt; </a>
{% endif %}
<span class="current">
&nbsp;Page {{ posts.number }} of {{ posts.paginator.num_pages }}
</span>
{% if posts.has_next %}
<a href="?page={{ posts.next_page_number }}"> &gt;&gt; older entries</a>
{% endif %}
</span>
</div>
{% endif %}
</div>
{% endblock %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.