I would like to know how to get the values in a template, from a variable called 'my_movie_code_count':
my_movie_code_count = Code.objects.values('movie__title').annotate(Count('movie'))
If I do a pprint to the console I get:
for m in my_movie_code_count:
pprint.pprint(m)
console output:
{'movie__count': 1, 'movie__title': u'THE MEN WHO STARE AT GOATS'}
{'movie__count': 3, 'movie__title': u'PIRATE RADIO'}
{'movie__count': 1, 'movie__title': u'A SERIOUS MAN'}
{'movie__count': 3, 'movie__title': u'GREENBERG'}
{'movie__count': 1, 'movie__title': u'MILK'}
{'movie__count': 1, 'movie__title': u'TEST'}
template: (Currently it doesn't show any output.)
{% for movie in my_movie_code_count %}
{{movie.title}}:{{movie.count}}
{% endfor %}
print(YourModl.objects.all().values()). Doesn't solve your problem but this was the only related question that came up.