Hello, i currently have two classes in my model:
class Post(models.Model):
prepopulated_fields = {"post_slug": ("post_title",)}
post_title = models.CharField(max_length=750)
post_slug = models.SlugField()
........................
def __unicode__(self):
return self.post_title
class Comment(models.Model):
comment_post = models.ForeignKey('Post')
comment_date = models.DateTimeField('Date comment made')
comment_body = models.TextField()
comment_spam = models.BooleanField(default=False)
comment_author = models.CharField(max_length=5000)
def __unicode__(self):
return unicode(self.comment_post)
-----------------------------------------------------------------------------------------------------------------------------------------
And i want a view that returns the post and all the related comments.
This is what i have:
def title_view(request, slug):
blog_posts = Post.objects.filter(post_slug=slug)
blog_comments = Comment.objects.filter(some filter)
return render_to_response('blogSite/comments.html', locals(),
context_instance=RequestContext(request))
this is what i have, this returns the post but i don't know what
filter to use to filter the comments, presuambly it should have
something to do with comment_post since that is the foreign key but i
don't know. I'd appreciate any help, i've tried doing it a number of
ways with no success.
Thanks,
Andrew
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---