4.6.5 Template for a List of Blog Posts
Create a new file /blog/templates/blog/post_list.html
, as shown in Example 4.44. The variable we pass data to is named post_list
.
blog/templates/blog/post_list.html
in 597bfb94f4
1 {% for post in post_list %} 2 <article> 3 <header> 4 <h2> 5 <a href=""> 6 {{ post.title|title }}</a> 7 </h2> 8 <p> 9 Written on: 10 <time datetime="{{ post.pub_date|date:"Y-m-d" }}"> 11 {{ post.pub_date|date:"l, F j, Y" }} 12 </time> 13 </p> 14 </header> 15 <p> {{ post.text|truncatewords ...
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.