class Post(models.Model):
title = models.CharField(max_length=255)
category = models.ForeignKey(Category)
...
class Comment(models.Model):
body = models.TextField()
post = models.ForeignKey(Post)
...
意见
def single_post(request,slug):
p = Post.objects.get(slug=slug)
cat = Category.objects.all()
return render_to_response('single_post.html',{'p':p,'cat':cat},context_instance=RequestContext(request))
如何从模板中的单个帖子中获取评论?