1
good morning! I have the following question:
I have a class Person, of which I can have 3 types of person (Victim, Aggressor and Witness) in the same form... as I would set the variables so that when saving to the database are 3 different attributes
ex.
Form of crimes against life
VICTIM
fom_vida.name
AGGRESSOR
form_vida.name
WITNESS
form-life.name
This in the same form, ie I want to differentiate the variables!
Hello Renan. I didn’t understand your answer:
class ForensicAgressor(models.Model):
name = models.CharField(max_length=100, blank=True, null=True, verbose_name='Nome')
birth = models.DateTimeField(blank=True, null=True, verbose_name='Data de Nascimento')
class ForensicVitima(models.Model):
name = models.CharField(max_length=100, blank=True, null=True, verbose_name='Nome')
birth = models.DateTimeField(blank=True, null=True, verbose_name='Data de Nascimento')
class ForensicPessoa(models.Model):
agressor = models.ForeignKey(ForensicAgressorn)
vitima = models.ForeignKey(ForensicVitima)
see above as it is, as I would in the same Form to set the value (input) of each object?
If victim, perpetrator and witness are objects of the same class, it may be necessary to add an attribute to the class, for example,
role
("role"). Hence a person may havename = "fulano"
androle = "agressor"
, another may havename = "beltrano"
androle = "testemunha"
etc..– Oralista de Sistemas
Hello Renan, I did not understand your answer, see above, I tried to rephrase the question
– Sara Fernandes
Hello, Sara. I never wore Django. I was wondering how the app would distinguish a victim from an attacker, for example, just by looking through the database. It’s just that you mentioned a class person, but I hadn’t seen that there are three distinct classes.
– Oralista de Sistemas