1
hello,
I am new to Django and I am trying to get information related to two different classes, with 1 variable as "base" for it. In case I have the Customer and Order class, and I would like to include a field where when selecting the Customer, appears in my Model the address of the same:
class Client(models. Model):
nome = models.CharField('Nome', max_length=50)
nome_fantasia = models.CharField('Nome Fantasia', max_length=50)
endereco = models.CharField('Endereço', max_length=50)
cidade = models.CharField('Cidade', max_length=50)
estado = models.TextField('Estado', max_length=12, choices=UF_CHOICES)
Order class(models. Model):
SIT_CHOICES = ((tirei pra nao ficar grande))
TIPO_CHOICES = (tirei pra nao ficar grande)
numero = models.CharField('Numero', max_length=9, unique=True)
situacao = models.CharField('Situação', max_length=12, choices=SIT_CHOICES)
data = models.DateField()
fornecedor = models.ForeignKey(Fornecedor, on_delete=models.SET(set_default_fornecedor))
cidade = models.CharField('Cidade', max_length=50)
**cidade_cliente = ??????????????**
cliente = models.ForeignKey(Cliente, on_delete=models.SET(set_default_cliente))
preco_produto = models.DecimalField('Preço', max_digits=8, decimal_places=2)
variedade = models.CharField('Variedade', max_length=12)
tipo = models.CharField('Tipo', max_length=12, choices=TIPO_CHOICES)
quantidade_pedido = models.IntegerField('Quantidade Pedido', help_text="Peso em Tonelada")
another question that I have already faced, that I will have several lines for each order, and I need to include also in the Request class "total order" basically would be a sum of all the launches of each order, in a new class that I will create as statement that is, again I come across the need to seek information of another class and demonstrate in this.
Anyway, to scanning the google answers and still not found result.