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 106453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:35:57+00:00 2026-05-11T01:35:57+00:00

Essentially I need a count of each Entries Comments: SELECT e.*, COUNT(c.id) as comments

  • 0

Essentially I need a count of each Entries Comments:

SELECT e.*, COUNT(c.id) as comments FROM blog_entry e LEFT JOIN blog_comment c ON e.id = c.entry_id GROUP BY e.id, e.name, e.name_slug, e.date_published, e.category, e.image, e.body, e.is_published, e.views, e.subscription_sent ORDER BY e.date_published DESC LIMIT 15; 

But I don’t know how to go about this using Django.

This is what I have so far, it works perfectly, except there’s no comment count. Can someone point me in the correct direction for making joins like this using Django?

from project.blog.models import Entry, Comment  def index(request):     latest_entry_list = Entry.objects.filter(is_published=True).order_by('-date_published')[:15]     return render_to_response('blog/index.html', {'latest_entry_list': latest_entry_list) 
  • 1 1 Answer
  • 0 Views
  • 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. 2026-05-11T01:35:57+00:00Added an answer on May 11, 2026 at 1:35 am

    django 1.1 have support for aggregate queries, you can grab the last version via the svn trunk. The doc is already updated

    http://docs.djangoproject.com/en/dev/topics/db/aggregation/

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

Sidebar

Ask A Question

Stats

  • Questions 62k
  • Answers 62k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer In most cases connection pooling problems are related to connection… May 11, 2026 at 9:59 am
  • added an answer I think you'll find that an Interface is the best… May 11, 2026 at 9:59 am
  • added an answer I suggest you to implement your event handling using commands… May 11, 2026 at 9:59 am

Related Questions

Essentially I need a count of each Entries Comments: SELECT e.*, COUNT(c.id) as comments
Essentially I want to know if in VB.NET 2005 if using a sqlcommand and
I'm looking for suggestions for a beginner level ASP/XML test. Essentially I'm trying to
I am currently trying to manipulate a unordered list with jQuery, essentially I have
We have a reverse proxy here, running Apache in version 2.2.x Essentially I want
I essentially want to spider my local site and create a list of all
I have essentially a survey that is shown, and people answer questions a lot
So What I'm essentially trying to do is have something happen 70% of the
Essentially the only thing I can deploy to my deployment machine is a JAR
I have what is essentially a jagged array of name value pairs - i

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.