2👍
✅
You could use a list comprehension:
content_per_year = [ ContentItem.objects.filter(timestamp__year=y).count() \
for y in range(2006, 2012) ]
👤miku
Source:stackexchange.com