Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 855041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:01:07+00:00 2026-05-15T08:01:07+00:00

I have a mini blog app, and a reply system. I want to list

  • 0

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

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T08:01:08+00:00Added an answer on May 15, 2026 at 8:01 am

    Firstly, please consider giving your variables sensible names. New, list and paginator do not at all describe what those objects actually are – and in some cases they are actively misleading, as with object_list which is not a list at all but a single item.

    Secondly, the code is doing exactly what you asked it to (ignoring the fact that the template code you have posted is actually invalid, because you are not nesting the loops properly and redefine the object variable). You get all entries, and all replies, then show the list of all replies underneath every entry.

    Instead, you obviously want to get the replies attached to each entry. So delete the lines referring to Reply in the view, and in the template make use of the reverse relationship:

    {% for object in list %}
      {{ object.post }}
      {% for reply in object.reply_set.all %}
        {{ reply }}
      {% endfor %}
    {% endfor %}
    

    Finally, as others have recommended in answer to your other questions, you would be well served by reading the Django tutorial and the Django book, both available freely online.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a mini blog app, and a 'timeline' . there i want to
I want to make a 'timeline' containing all mini blog posts from a user,
i have a mini app where users can login, view their profile, and follow
A lot of these pages are like mini applications that have their own CSS
I want to create a 'mini-database'. I want to have one file with lots
i'm trying to build a mini reply system, based on the user's posts on
I have a mini API that is only for an app I have built.
I have mini recursive function which finds and hides all .mta files. It looks
I have Mac mini machine It has 10.3.9 Mac OS. Now I want to
I want to start programming for iOS-devices. I have mac mini and IPad 2.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.