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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:42:33+00:00 2026-05-19T23:42:33+00:00

I am creating a TODO list that categorizes tasks by their status. IE: Waiting,

  • 0

I am creating a TODO list that categorizes tasks by their status. IE: Waiting, Today, Tomorrow, Scheduled. My models look something like:

class Status(models.Model):
    title = models.CharField(max_length=32)

class Task(models.Model):
    user = models.ForeignKey(User)
    status = models.ForeignKey(Status, default=1)
    title = models.CharField(max_length=128)
    notes = models.TextField(blank=True)
    completed = models.BooleanField()

I want to create a navigation list that displays all of the statuses (which is simple) but also the count of how many tasks are assigned to each (that is where I am stuck).

Waiting(1)
Today(3)
Tomorrow(1)
Scheduled (0)

It needs to be able to produce the status even if the count is 0. It’s a navigational list and I want the user to be able to see where they can put a task.

Status.objects.all()

Above will get me my list but I don’t know how to get the count of tasks. I figure I have to work in reverse, pull a list of tasks and group them by my Status model but I am at a loss on how to do that.

  • 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. Editorial Team
    Editorial Team
    2026-05-19T23:42:33+00:00Added an answer on May 19, 2026 at 11:42 pm

    Django’s aggregation features can do this quite simply.

    from django.db.models import Count
    statuses = Status.objects.all().annotate(Count('task'))
    

    Now each item in statuses has an attribute task__count which is the number of tasks related to that status.

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

Sidebar

Related Questions

How to do that without creating any new collections? Is there something better than
I'm creating a generic list class that has a member of type Array(Array of
Here is my problem. I have a list of models that are displayed to
Here is my problem. I have a list of models that are displayed to
I am creating a php todo list and have an 'admin_todo' table in a
Am following the tutorial here on creating a simple todo list app: http://www.mydroid.apnafundaz.com/2010/07/todolist-application-in-android-step-by-step-guide-with-screen-shots/ Have
I have a Todo List (an ASP.MVC UserControl) that for each row has the
I'm creating an EnityList to do some client side testing with my ViewModel. Something
I created the following route: map.todo todo/today, :controller => todo, :action => show_date Originally,
I'm creating an application and I have a FragmentPager that I use. To use

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.