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

  • Home
  • SEARCH
  • 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 7579241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:37:41+00:00 2026-05-30T17:37:41+00:00

Currently I have three models in Django that create a circular reference: A User

  • 0

Currently I have three models in Django that create a circular reference:

A User can live in a Location.
A Location must be part of a Property.
A Property must have an owner, which is a User.

The reason I want each User to specify a location is for people living in apartments. An apartment tenant would live in a numbered room, but a house tenant wouldn’t. But notice that location can also simply be just a property (ie a house tenant lives in a location which is just the property with an address; the property doesn’t have room numbers, floors, or buildings.).

Here is the (stripped down) code:

class User( models.Model ) :
    TYPE_CHOICES = (
        ( 't', 'tenant'           ),
        ( 'o', 'property owner'   ),
        ( 'v', 'vendor'           ),
        ( 'm', 'property manager' ),
    )

    user_type  = models.CharField( max_length = 1, choices = TYPE_CHOICES, default = 't' )
    first_name = models.CharField( max_length = 135 )
    last_name  = models.CharField( max_length = 135 )
    location   = models.ForeignKey( Location, null = True, blank = True )

class Property( models.Model ) :
    name             = models.CharField( max_length = 135 )
    owner            = models.ForeignKey( User )
    address_line_one = models.CharField( max_length = 135 )
    address_line_two = models.CharField( max_length = 135, blank = True )
    city             = models.CharField( max_length = 135 )
    state            = models.CharField( max_length = 135 )
    zip_code         = models.CharField( max_length = 135 )

class Location( models.Model ) :
    room       = models.CharField( max_length = 135, blank = True )
    floor      = models.CharField( max_length = 135, blank = True )
    building   = models.CharField( max_length = 135, blank = True )
    prop       = models.ForeignKey( Property )

Please let me know if you guys need more clarification or code. Thanks in advance!

  • 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-30T17:37:43+00:00Added an answer on May 30, 2026 at 5:37 pm

    Like the docs say, you can use a string to specify the app and model to use in a relation.

    If you need to create a relationship on a model that has not yet been defined, you can use the name of the model, rather than the model object itself

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

Sidebar

Related Questions

Currently I have the from django.contrib.auth.models import User but I'm confused as to how
Can you use contrib.auth.models.User or any of contrib.auth along with Django MongoDB Engine ?
I'm writing a django model that allows my site to have coupons. Coupons can
I'm trying to create a Django app where the user can make a list
I'm currently exploring django forms and have a issue I hope someone can help
I have three different models that will be involved with this. I am trying
So I currently have three unordered lists in my header. This is a single-page
I currently have mirroring setup between three computers, principle, mirror, and witness. During the
I have three divs: A, B and C. A is currently visible and I
We currently have an application that depends largely on stored procedures. There is 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.