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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:45:40+00:00 2026-05-23T01:45:40+00:00

I have to admit that I got pretty rusty with django, so I’m sorry

  • 0

I have to admit that I got pretty rusty with django, so I’m sorry if the question is too simple.

I have a couple of models like the followings:

class Monograph(models.Model):
    monid = models.AutoField(primary_key=True)
    title = models.CharField("Title", max_length=2000)
    .............

class Isbn(models.Model):
    isbnid = models.AutoField(primary_key=True)
    monid = models.ForeignKey(Monograph, db_column='monid')
    isbnnum = models.CharField("ISBN", max_length=20)
    .............

What I want to extract is the list of Monographs that don’t appear in the table of ISBN.

In SQL I would write this query like:

SELECT * FROM Monograph WHERE monid NOT IN (SELECT monid FROM Isbn)

Any idea?

Thanks!

  • 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-23T01:45:41+00:00Added an answer on May 23, 2026 at 1:45 am

    One way would be:

    Monograph.objects.exclude(monid__in=Isbn.objects.values_list('monid', flat=True))
    

    See docs for values_list() and __in field lookup.

    Another way would be (I think this version would hit DB only once):

    Monograph.objects.filter(isbns=None)
    

    You’ll need to specify related_name='isbns' on the foreign key from Isbn to Monograph for this to work. (See docs for details on backward relationships.)

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

Sidebar

Related Questions

I have to admit that I'm new to Java and Android. db4o seems to
I admit that I have almost none experience of unittesting. I did a try
I have just installed Microsoft Robotics Studio 2008 R2, and I must admit that
I've got pretty much the same question as: Jabber Openfire server v3.6.0a+ - how
I've got a simple WCF service that works great on localhost - consumed by
I'm using Django 1.1, and I have this template, a base template, that all
We've got a pretty typical django app running on postgresql 9.0. We've recently discovered
i have to admit, i never really completely got the *nix filesystem permission model.
This might seem like a stupid question I admit. But I'm in a small
In my app I have a table for ROLES. Pretty simple: 1: Admin, DESC

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.