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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:58:29+00:00 2026-05-23T21:58:29+00:00

I am annotating my queryset in Django, using values from another table mapping as

  • 0

I am annotating my queryset in Django, using values from another table mapping as so.

    lw_list = lw_list.annotate(count_mapping=Count('mapping'))

(lw objects have a one to many relationship with the mapping objects)

So now each object in my lw list has a count of related mapping objects.
My mapping objects have a boolean field ‘pass_fail’

Is it possible to put a where clause on the mapping table, so that the aggreagte only counts mapping objects that have a “pass_fail” value set to true?

How do you do this?

  • 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-23T21:58:29+00:00Added an answer on May 23, 2026 at 9:58 pm

    I don’t think this can be done using Django’s ORM as of now — here’s a pretty active ticket about what you want, and here’s a pretty hackish workaround suggested by someone in there. I’d say your best bet would be to use raw SQL for now.

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

Sidebar

Related Questions

I'm considering using Annotations to define my Hibernate mappings but have run into a
Basically I want to do something similar to annotating a queryset but with a
I have a problem with transactions in that annotating a service that calls a
Background: I am in the process of annotating SNPs from a GWAS in an
I'm thinking of annotating my Domain Objects. This will ease manipulation of the DOs.
I am creating a SOAP service using JAX-WS and JAXB, by annotating the classes.
I have a simple question about usage of Hibernate. I keep seeing people using
I'm annotating sensor observations using JENA, RDF and the W3C SSNXG's sensor ontology. I've
I have a web service app on Apache Geronimo 2.1.3. I am using JAX-WS,
I have a class that I am creating a Hibernate mapping which contains a

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.