On Jun 10, 6:13 am, Chris McComas <mccomas.ch...@gmail.com> wrote:
> I have this views.py and models.py:
>
> http://dpaste.com/552615/
>
> On the view what I want to do is display a list of all the feed types
> (News, Sports, etc general categories), then then below each of those
> feed type headings display the FeedItems for each feed for that city.

Which city ?

> Prior to adding the City model it was pretty easy, I was able to just
> do this in my template:
>
> http://dpaste.com/552616/
>
> Maybe it's because it's late and I'm out of coffee, but this is
> totally stumping me on how to do this best. Any help would be greatly
> appreciated!

Assuming the city is passed as an argument to the view (dummy code,
may have a few errors):

# views.py

def news(request, city_id):
    city = get_object_or_404(City, pk=city_id)
    feeds = Feed.objects.filter(city=city).select_related("type")
    return render_to_response(
        "path/to/template.html",
        dict(city=city, feeds=feeds)
        )

then in you template you just {% regroup %} feeds by type,cf
https://docs.djangoproject.com/en/1.3/ref/templates/builtins/#regroup

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to