Hi Guys,
Ok got a bit of a tricky one here for some reason. Basically I am
doing a query which returns a list of albums your friends own.
The problem is that I need to group the results by the album id so
that I only get a unique list of albums.
Now what I've noticed is that the number of results (count) is
different between the results that have not been group and those that
have. Hopefully the code below makes some sense:
###############################################
// get results
friends_albums = Albums.objects.filter(users__in=friend_list,
date__gte=today).extra(select={'count': 'count(1)'}).select_related()
// count results
count['friends1'] = friends_albums.count()
// now group by
friends_albums.query.group_by = ['album_id']
// count results again once grouped
count['friends2'] = friends_albums.count()
###############################################
So count['friends1'] counts the results before being grouped, but once
I group them in the line after, count['friends2'] returns a different
number.
The count in the extra parameter in the query is the correct number I
want, but I can't figure out how to access this within the View.pm
file?
Any ideas? I'll try and provide some examples of data when I get home
if this isn't enough information.
Cheers,
Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---