Login

very archive template

Author:
stuntgoat
Posted:
October 19, 2009
Language:
HTML/template
Version:
Not specified
Tags:
archive blog-entry
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

  1. very archive view by stuntgoat 5 years, 10 months ago
  2. Format transition middleware by limodou 8 years, 6 months ago
  3. Using reverse() to do redirects by ubernostrum 8 years ago
  4. Improved generic foreign key manager 2 by Nomalz 5 years, 10 months ago
  5. Template Query Debug by insin 8 years, 5 months ago

Comments

Please login first before commenting.