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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:32:52+00:00 2026-05-13T18:32:52+00:00

What is the appropriate way to create an instance of the following two models

  • 0

What is the appropriate way to create an instance of the following two models

class Administrator(models.Model):
    user = models.OneToOneField(User, primary_key=True)
    account = models.ForeignKey(Account)

class Account(models.Model):
    owner = models.OneToOneField(Administrator)

Both require each other. An account cannot exist without a primary user (owner), and an administrator (which is what owner is) cannot exist without an account. Yes a general User object can exist on it’s own but I can’t wrap my brain around which of these should come first and how to implement that correctly. If I have to use blank=True on Administrator’s account attribute I will, but is there a better way? Should I use a transaction to ensure one cannot exist without the other?

  • 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-13T18:32:53+00:00Added an answer on May 13, 2026 at 6:32 pm

    If two models exist such that each requires the other, they should usually be combined into a single model.

    In any case there is probably a better way to structure the classes. Personally I would construct a UserProfile class as follows:

    class UserProfile(models.Model):
        user = models.OneToOneField(User)
        administrator = models.BooleanField()
    

    or possibly:

    class UserProfile(models.Model):
        user = models.OneToOneField(User)
    
    class AdministratorProfile(UserProfile):
        # attributes
    

    or even:

    class UserProfile(models.Model):
        user = models.OneToOneField(User):
    
    class AdministratorProfile(models.Model):
        profile = models.OneToOneField(UserProfile)
    

    any of these methods should work.

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

Sidebar

Related Questions

What's the appropriate way to get the non-handle type in the following code: template
After searching, I dont find the appropriate way to resolve following problem. After activating
I want to create a model that will order its children models in the
What is the appropriate way to flip an ExtJs Panel horizontally for RTL languages,
I am looking for an appropriate way to store and access pdf files in
I'm not sure whether or not this is the appropriate way of doing this,
would it be appropriate to use PHP's sscanf to read user submitted sentences and
So, I am asking about how to create the appropriate concept/solution for a problem
I'm attempting to create a library whose API will be used in the following
Well, I need to return a pointer to an instance of a class that

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.