What is the proper way to add a OneToOneField in Django? Does it go in the parent class or child class? The official docs don't really explain this. Which way works better with the built-in admin interface? Does it matter? Is there a convention?
What is the "correct" way?
class Client(models.Model):
name = models.CharField(max_length=30)
portfolio = models.OneToOneField(to="Portfolio", null=True, on_delete=models.CASCADE)
class Portfolio(models.Model):
... portfolio fields ...
or
class Client(models.Model):
name = models.CharField(max_length=30)
class Portfolio(models.Model):
client = models.OneToOneField(to="Client", null=True, on_delete=models.CASCADE)
... portfolio fields ...
I see most examples add it to the child, but it seems adding it to the parent works better with the admin interfaces and makes more sense logically.