Skip to content
pkirlin edited this page Oct 12, 2016 · 19 revisions

Using the Python SQLite interface with HTML templates

In this lesson we will build a nicer view of our blog entries, rather than the "dump" output which is ugly.

First, let's create a new HTML template (our first one for the blog!). Inside the templates/ subfolder, create a file called browse.html:

<html>
  <head>
    <title>Browse entries</title>
  </head>
<body>
  <h1>Browse entries</h1>
  {% if entries %}
  <ul>
    {% for entry in entries %}
      <li><b>{{ entry.title }}</b> ({{ entry.date }})<p>{{ entry.content }}<hr>
    {% endfor %}
  </ul>
  {% else %}
  This blog is empty.
  {% endif %}
  </ul>
</body>
</html>

Use the main wiki page to navigate, not the list of pages directly above, because those are out of order.

Clone this wiki locally