django blog - post- reply system display replies
- by dana
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