Looking to make a generic view archive page by month and year.
Like this:
2011 - January March
2010 - October December
What I am getting:
2011 - January January
2010 - January January
Is this possible? Here are the views and templates.
view
def track_archive(request):
return date_based.archive_index(
request,
date_field='date',
queryset=Track.objects.all(),
)
track_archive.__doc__ = date_based.archive_index.__doc__
template
{% for year in date_list %}
<a href="{% url track_archive %}{{ year|date:"Y" }}/">{{ year|date:"Y" }}</a> archives:
{% for month in date_list %}
<a href="{% url track_archive %}{{ year|date:"Y" }}/{{ month|date:"b" }}/">{{ month|date:"F" }}</a>
{% endfor %}
{% endfor %}
According to the doc,
archive_indexonly calculates the years. You might want to write the year/month grouping:Your template:
y and m are date objects, you should be able to extract any date format information to construct your urls.