我正在尝试获取每个月的所有帖子,例如7月有11个帖子,而8月有1个帖子。但是现在,当它循环播放时,我每个月都有一个帖子。
这将是结果:
2019 Aug (1) Time Lapse Video vs. Time Lapse Photo Test
Jul (11) A simple Tutorial about how to add Facebook login in your website.
这是我在模板上的代码:
{% regroup events by timestamp.year as year_list %}
{% for year in year_list %}
{{ year.grouper }}
{% regroup events by timestamp.month as month_list %}
{% for month in month_list %}
{{ month.list.0.timestamp|date:"M"}} ({{ month.list|length }})
{% for post in events %}
{% if post.timestamp == month.list.0.timestamp %}
{{post.title}}<br>
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
我希望在7月的剩余时间里。谢谢。