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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:52:45+00:00 2026-05-21T10:52:45+00:00

I have two apps – one for dogs and one for litters – where

  • 0

I have two apps – one for dogs and one for litters – where ideally I would have foreign keys back to each other, something like this:

In dogs.py:

from litters.py import Litter
class Dog(models.Model):
    name = models.CharField(max_length=55)
    Litter = models.ForeignKey(Litter, blank=True)

In litters.py

from dogs.py import Dog
class Litter(models.Model):
    name = models.CharField(max_length=55)
    sire = models.ForeignKey(Dog, related_name='dog_sire_set')
    dam  = models.ForeignKey(Dog, related_name='dog_dam_set'

When creating a new litter, I want the litter’s dam and sire (mom and dad) to come from my table of dogs, hence the two FK’s to dam and sire. So before I can create a litter, I must have at least two dog entries.

Later, when describing new dog entries, I want to know the dog’s litter if known, and that litter should be from my litter table. It should not be required that a dog have a litter, but if that field is not null, then I’d like to know it.

The code above will not work but it demonstrates what I want to achieve. I’d be appreciative of any tips on how to solve this. 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-21T10:52:46+00:00Added an answer on May 21, 2026 at 10:52 am

    blank=True tells admin that this field is not required to be entered by user. But you still to tell DB same thing, you need to add null=True. And if you have circular import problem, put model name as a string.

    Litter = models.ForeignKey('Litter', blank=True, null=True)
    

    If there’s no litter, the field will have None.

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

Sidebar

Related Questions

I have to pass parameters between two rails apps. In one side (sender) I
I have two applications written in Java that communicate with each other using XML
I have two cocoa-touch apps in one Xcode project. Xcode gives me iPhone/iPad related
i have two iphone apps and want to they able to switch via a
I have a project with two silverlight apps (foo1 and foo2) and an ASP.NET
I have two classes, and want to include a static instance of one class
I have two threads, one needs to poll a bunch of separate static resources
I have two free apps, iSys and iSysMonitor, that report info about my iPhone.
I have two arrays of animals (for example). $array = array( array( 'id' =>
I have two arrays of System.Data.DataRow objects which I want to compare. The rows

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.