4.6.4 Template for a Single Blog Post

Create a new file /blog/templates/blog/post_detail.html, as shown in Example 4.43. We plan to pass data to a post variable.

Example 4.43: Project Code

blog/templates/blog/post_detail.html in b04022d368

 1  <article>  2  3      <header>  4        <h2> {{ post.title|title }}</h2>  5        <p>  6          Written on  7          <time datetime="{{ post.pub_date|date:"Y-m-d" }}">  8            {{ post.pub_date|date:"l, F j, Y" }}  9          </time> 10        </p> 11      </header> 12 13      {{ post.text|linebreaks }} 14 15    {% if post.startups.all or post.tags.all %} 16      <footer> 17 18        {% if post.startups.all %} 19            <section> 20              

Get Django Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.