I am trying to count the distinct values from a group of objects that have a manytomanyfield
e.g.
object article has manytomanyfield of tag objects
one article has tags "tag1" "tag2"
another article has tags "tag2" "tag3"
I would like to figure out something that would return something along the lines of:
"tag1": 1 "tag2": 2 "tag3": 1
I thought I could do something with articles.objects.all().values('tags') or something but I came up empty.
You question is related: How to count and display objects in relation ManyToMany in Django
models.py
python manage.py shell
models.py
python manage.py shell