1
Ola, I’m starting to study python on account of Django. I have a question that many may consider trivial but I don’t know the answer.
I am building a Model with the following features:
class Candidato(models.Model):
nome = models.CharField(max_length=300, required=True)
mail = models.EmailField(max_length=300, required=True)
fone = models.CharField(max_length=20, required=True)
nascimento = models.DateTimeField(blank=False, null=False)
cpf = models.CharField(max_length=50, required=True)
rg = models.CharField(max_length=50, required=True)
trabalho = models.EmailField(max_length=300, required=True)
mae = ???????????
pai = ???????????
And I need the fields "mother" and "father" to be two objects with the following structure:
class Mae(models.Model):
nome = models.CharField(max_length=300, required=True)
nascimento = models.DateTimeField(blank=False, null=False, required=True)
cpf = models.CharField(max_length=50, required=True)
rg = models.CharField(max_length=50, required=True)
mail = models.EmailField(max_length=300, required=True)
fone = models.CharField(max_length=20, required=True)
trabalho = models.EmailField(max_length=300, required=True)
class Pai(models.Model):
nome = models.CharField(max_length=300, required=True)
nascimento = models.DateTimeField(blank=False, null=False, required=True)
cpf = models.CharField(max_length=50, required=True)
rg = models.CharField(max_length=50, required=True)
email = models.EmailField(max_length=300, required=True)
fone = models.CharField(max_length=20, required=True)
trabalho = models.EmailField(max_length=300, required=True)
membro = models.BooleanField()
How do I reference an object "Father" and a "Mother" within the object "Candidate"?
I am grateful for the help of those who can help me.
I will read about this type of relationship. Thank you very much for your help :D
– Vitor Hugo
Welcome to Stack Overlfow! : ) If the answer has solved your problem, don’t forget to mark as accepted.
– Leonardo Pessoa