Book Image

Django 1.0 Template Development

Book Image

Django 1.0 Template Development

Overview of this book

Table of Contents (17 chapters)
Django 1.0 Template Development
Credits
About the Author
About the Reviewers
Preface
Index

Putting navigation into the templates


Before we can see the output of our work in a browser, we need to put together the template and build in the appropriate navigation to go to the next and previous pages.

Edit the mycompany/templates/press/list.html file to look like this:

<html>
<head>
<title>Press Releases</title>
</head>
<body>
<h1>Press Releases</h1>
<ul>
{% for press in press_list %}
<li>
<a href="{{ press.get_absolute_url }}">
{{ press.title }}</a>
</li>
{% endfor %}
</ul>
<p>
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
</p>
<p>
{% if page_obj.has_previous %}
<a href="?page={{ page_obj.previous_page_number }}">Previous</a>
{% else %}
Previous
{% endif %}
&nbsp;|&nbsp;
{% if page_obj.has_next %}
<a href="?page={{ page_obj.next_page_number }}">Next</a>
{% else %}
Next
{% endif %}
</p>
</body>
</html>

Note

If you have...