On Wed, Jun 18, 2008 at 11:21 PM, Austin Govella
<[EMAIL PROTECTED]> wrote:
> I'm pulling all events for a city:
>
> events = Event.objects.filter(city=city)
>
> Each event can have a set of attractions like food, dancing, drama,
> djs, live music, art, etc.
>
> How do I query the list of attractions for events in that city? (Query
> all attractions that are tied to events in that city)

You're looking for "lookups that span relationships":
http://www.djangoproject.com/documentation/db-api/#lookups-that-span-relationships

In this case, you want something like "filter the attractions in such
a way that the name of the city of the related event is ... and
eliminate duplicates in the resulting list":

  attractions = Attraction.objects.filter(event__city__name='...').distinct()

The details depend on your exact models, but that's the idea.


Arien

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