0
尋求按月份和年份製作通用視圖歸檔頁面。 像這樣:Django具有通用視圖的年份/月歸檔頁面
2011 - January March
2010 - October December
什麼我得到:
2011 - January January
2010 - January January
這可能嗎?這裏是視圖和模板。
視圖
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 %}