Ok, i have a model like this:

class Tag(models.Model):
        tagname = models.SlugField()
        def __str__(self):
                return self.tagname
        class Admin:
                pass
class Post(models.Model):
        title = models.CharField(max_length=200)
        slug = models.SlugField(prepopulate_from=('title',),
help_text="automatically generated from title")
        pub_date = models.DateTimeField('Date published')
        body = models.TextField()
        tags = models.ManyToManyField(Tag)
        lead_image = models.ImageField(upload_to='images/blog/', blank=True)
        def __str__(self):
                return self.title
        class Admin:
                pass

How do i write a view to view all posts with a certain tag?



I'm here at the moment, but it' not working:

from django.shortcuts import render_to_response, get_list_or_404,
get_object_or_404
from jj.blog.models import Tag, Post


def tag(request, tag):
        filtertag = get_object_or_404(Tag, tagname=tag)
    post = get_list_or_404(Post, tags__in=filtertag)

    return render_to_response('index.html', {'page_record': post})



I've tried a number of ways and researched like crazy but the debug
just gives me a 404 with no debug info, I'm having a hard time.

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