Thanks for all the help.

I ended up using this:

View...
s = User.objects.all().values('id', 'username', 'first_name',
'last_name',)
users = []
for u in s:
        p = Poem.objects.filter(user=u['id'], approved=True)
        users.append({
                        'id':                   u['id'],
                        'username':     u['username'],
                        'first_name':   u['first_name'],
                        'last_name':    u['last_name'],
                        'poems':                p,
                })


Template...
{% if users %}
<ul>
{% for user in users %}
<li>{{ user.first_name }} {{ user.last_name }}, {{ user.poems.count }}
Poems</li>
{% endfor %}
</ul>
{% endif %}

On Aug 13, 9:49 pm, Collin Grady <[EMAIL PROTECTED]> wrote:
> Regroup generates a list of dicts with two keys - grouper (the value
> of the field you're grouping by) and list (the list of objects that
> match that)
>
> So in this case, you get entries like {'grouper': <User: John Smith>,
> 'list': [<Poem: Roses are red>, <Poem: Violets are blue>, ...]}  :)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to