On Jun 19, 5:21 am, Austin Govella <[EMAIL PROTECTED]> wrote:
> I'm confused on what part of the docs I'm supposed to reference:
> *http://www.djangoproject.com/documentation/db-api/
>
> 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)
>
> For example, Houston might have rodeo attractions, but Pittsburgh
> might not. On the Houston page, I'd like the attractions list to
> include rodeo. On the Pittsburgh page, I don't want to see it.
>
> Seems easy, but I'm missing something. Pointers to the proper docs
> appreciated.
>
> Thanks,
> --
> Austin Govella

You don't say how your attractions are related to your cities. Is it a
set of booleans on the model? If so, you'd just do
{% if city.rodeo %}Rodeo{% endif %}
etc.

Hopefully you've gone down a more sensible route and used a foreign
key (or a many-to-many key) to an Attraction model. In which case your
template would have:
{% for attraction in city.attraction_set.all %}{{attraction.name}}{%
endfor %}

Does this answer your question? This is all documented under the
'Related objects' heading on the page you link to above.

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