django blog - post- reply system display replies

Posted by dana on Stack Overflow See other posts from Stack Overflow or by dana
Published on 2010-06-01T13:08:21Z Indexed on 2010/06/01 13:23 UTC
Read the original article Hit count: 314

Filed under:
|
|
|
|

I have a mini blog app, and a reply system. I want to list all mini blog entries, and their replies, if there are any. i have in views.py

def profile_view(request, id):
        u = UserProfile.objects.get(pk=id)
        paginator = New.objects.filter(created_by = request.user) 
        replies = Reply.objects.filter(reply_to = paginator)
    return render_to_response('profile/publicProfile.html', {
        'object_list': u,
        'list':paginator,
        'replies':replies
        }, 
        context_instance=RequestContext(request)) 

and in the template:

<h3>Recent Entries:</h3>
     {% for object in list %}
<li>{{ object.post }} <br />
{% for object in replies %}
{{ object.reply }} <br />
{% endfor %}

mention : reply_to is a ForeignKey to New, and New is the name of the 'mini blog' table

But it only shows all the replies for each blog entry, not the reply for every entry, if there is one

thanks

© Stack Overflow or respective owner

Related posts about django

Related posts about template