Hi all,

I'm using an intermediate table of Activities to relate Musicians,
Instruments, and Groups. Is there a good way to select groups from the
musician's activities? I've been doing stuff like [act.group for act
in theMusician.activity_set.all()]. This works pretty well, except
that there are duplicates if a musician plays more than one instrument
in a group, and merely doing set( the_above ) doesn't get rid of them
even though group1==group2 evaluates to True.

Is there some better way to do this? It seems strange to be trying to
remove the duplicates at this level rather than at the SQL level with
a distinct(). The resulting SQL (which I don't want to write myself)
should be something like:

SELECT DISTINCT *
FROM `app_group`
WHERE `id`
IN (

SELECT `group_id`
FROM `app_activity`
WHERE `musician_id` = 1
)

Thanks,
Andy


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to