Python 重新组合返回非类型的石斑鱼(当它不应';T
我目前正在尝试使用RegroupTemplate标记,按博客文章发布的年份来排列它们的发布日期列表 我传递到上下文中要重新分组的查询集是:Python 重新组合返回非类型的石斑鱼(当它不应';T,python,django,Python,Django,我目前正在尝试使用RegroupTemplate标记,按博客文章发布的年份来排列它们的发布日期列表 我传递到上下文中要重新分组的查询集是: 'post_archive_months': Post.objects.published().\ filter(site__id=settings.SITE_ID).dates('publish','month').reverse(), 在模板中,我将其称为: <section class="blog_archive_block">
'post_archive_months': Post.objects.published().\
filter(site__id=settings.SITE_ID).dates('publish','month').reverse(),
在模板中,我将其称为:
<section class="blog_archive_block">
<h4>Blog Archive</h4>
{% regroup post_archive_months by year as post_archive_dates %}
<ul class="" id="">
{% for year in post_archive_dates %}
<li>
<div class="header_box">
<h4>{{year.grouper}} <a href="#" class="arrow_up"></a></h4>
</div>
<div class="content_box">
<ul class="month">
{% for month in year.list %}
<li>
<a href="/blog/{{year.grouper}}/{{month|date:'M'}}">{{month|date:"F"}}</a>
</li>
{% endfor %}
</ul>
</div>
</li>
{% endfor %}
</ul>
</section>
博客存档
{%按年度将邮政存档月份重新分组为邮政存档日期%}
{年后存档日期中的百分比%}
-
{{year.gropper}}
{年中月份的百分比。列表%}
-
{%endfor%}
{%endfor%}
返回的数据是:
[{'list': [[datetime.datetime(2012, 9, 1, 0, 0, tzinfo=<UTC>), datetime.datetime(2012, 5,
1, 0, 0, tzinfo=<UTC>), datetime.datetime(2012, 4, 1, 0, 0, tzinfo=<UTC>),
datetime.datetime(2011, 10, 1, 0, 0, tzinfo=<UTC>), datetime.datetime(2011, 8, 1, 0, 0,
tzinfo=<UTC>)]], 'grouper': None}]
[{'list':[[datetime.datetime(2012,9,1,0,0,tzinfo=),datetime.datetime(2012,5,
1,0,0,tzinfo=),datetime.datetime(2012,4,1,0,0,tzinfo=),
datetime.datetime(2011,10,1,0,0,tzinfo=),datetime.datetime(2011,8,1,0,0,
tzinfo=)]],“石斑鱼”:无]
我本以为石斑鱼会是一年,或者至少是一种非石斑鱼以外的东西,但事实似乎并非如此
如果您需要我提供更多信息,请告诉我。谢谢