0
After seeing a modeling that I should implement in Django, I was a little confused and I will explain what I tried to do and what was sent to me. The following image is the relationship I should implement in Django
What I tried to do was:
class Contato(models.Model):
pessoa = models.OneToOneField(Pessoa)
class Pessoa(models.Model):
contato = models.ForeignKey(Contato)
But this does not work, both classes are in the same file. I read the documentation of Manytomanyfield, Onetoonefield and Foreignkey, but what makes me confused is the model wanting the varialvel in the two classes, in previous models that I saw existed this same relation, but the varialvel only existed in one of the classes. What is the right way to implement this?
Hello, Paulo, after performing some tests I had already come to the same conclusion as you, so I will consider your answer as the correct one since the implementation was similar. Thank you.
– Leonardo Furtado