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?