- Author:
- stuntgoat
- Posted:
- October 19, 2009
- Language:
- HTML/template
- Version:
- Not specified
- Score:
- 0 (after 0 ratings)
I tried to think of a way to use generic views to show all my blog posts on one page organized chronologically with each post title under one month name and all the month names under one year name.
Like so:
`
2009
October
My last example blog entry
Entry even before the last one
First of October
September
Only one entry in Sept.
2008
December
It is cold in December
First posting of my blog
`
I could not think of a way to do this using generic views, before I wrote a view and some template logic that does.
The view code is here:
http://www.djangosnippets.org/snippets/1766/
Any suggestions for design patterns are greatly appreciated.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | {% for year_dict in archive_list %}
{% for year_date, months_list in year_dict.items %}
<h2>{{ year_date }}</h2>
{% for month_list in months_list %}
{% for month_name, entries in month_list.items %}
<h3><p class="indented">{{ month_name }}</p></h3>
{% for entry in entries %}
<p class="indented-more"><a href={{ entry.get_absolute_url }}>{{ entry.title }}</a></p>
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
{% endfor %}
|
More like this
- Bootstrap Accordian by Netplay4 5 years, 11 months ago
- Bootstrap theme for django-endless-pagination? by se210 8 years, 11 months ago
- Bootstrap theme for django-endless-pagination? by se210 8 years, 11 months ago
- Reusable form template with generic view by roldandvg 9 years ago
- Pagination Django with Boostrap by guilegarcia 9 years, 2 months ago
Comments
Please login first before commenting.