Skip to content

Instantly share code, notes, and snippets.

@FernandoEscher
Created February 4, 2011 01:38
Show Gist options
  • Save FernandoEscher/810594 to your computer and use it in GitHub Desktop.
Save FernandoEscher/810594 to your computer and use it in GitHub Desktop.
Conteo de mensajes por cada usuario
from django.contrib.auth.models import User
from django.db.models import Count
ul = User.objects.annotate(Count('_message_set'))
for u in ul:
print '%s: %s'%(u.username, u._message_set__count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment