Hi,

I am writing a blog as my first app in Django. I have got a view that
works ok, but I need to filter this further so that it brings up all
stories that have the matching tag, but also were created before
todays date.

The tags are in a many to many relationship with the stories.

I am unsure of the syntax to do so. Can anyone please help ?

Thank you



This is my view:

# Create your views here.

from django.shortcuts import render_to_response
from django.views.generic.list_detail import object_list
from mysite.blog.models import Story, Tag
from django.template import Context, loader
from django.http import HttpResponse

def stories_by_tag(request, slug):

        tag = Tag.objects.get(slug=slug)
        story_list = tag.story_set.order_by('-pub_date', 'title')

        t = loader.get_template('blog/stories_by_tag.html')
        c = Context({
                'object_list': story_list,
                'tag_name': tag.name,
        })

        return HttpResponse(t.render(c))


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