django - Count multiple terms -


class term(models.model):     created = models.datetimefield(auto_now_add=true)        term = models.charfield(max_length=255)              

hey guys, try count duplicate/multiple terms db table still list of items ({term: a, count: 1, term: a, count: 1,term: b, count: 1,...}) of table , not {term: a, count: 12, term: b, count: 1}

has idea?

edit:

ee = term.objects.annotate(count("term")).values("term", "term__count") 

result:

[{'term': u'tes', 'term__count': 1}, {'term': u'tes', 'term__count': 1},  

what expected:

[{'term': u'tes', 'term__count': 2},  {'term': 'b', 'term__count': 1} 

https://docs.djangoproject.com/en/dev/topics/db/aggregation/ says order being important. also, if have order_by on model, affect it. how ...

ee = term.objects.values("term").annotate(count("term")).order_by() 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -