I have a list of values I want to display in a template of django.
The list is more or less like this:
199801 string1
199802 string2
199904 string3
200003 string4
200011 string5
where the first column is a date in the form YYYYMM and the second is a generic string
the list is ordered by date desc
What I want to create is a list of stringx grouped by year something like this:
1998 string1, string2
1999 string3
2000 string4, string5
I gave a look to the documentation and I think the only thing I need is a way to create a variable where to store the "last year" I printed, so I can do something like:
if current_value.year != last_year
#create a new row with the new year and the string
else
#append the current string to the previous one
I think the only way I found is to write a custom templatetag and let it store the variable and the value... but before starting to write code I would like to know if there is a simpler way!