[Answered ]-Django better way to filter dates without hard coding in the view

2👍

You could use a list comprehension:

content_per_year = [ ContentItem.objects.filter(timestamp__year=y).count() \ 
    for y in range(2006, 2012) ]
👤miku

Leave a comment