DJANGO > Render one FOR inside another

Asked

Viewed 130 times

2

I have a situation that is as follows:

I need to make a Tablea in html where I have to show the totalizers and a line and the values that make up this totalizer, as a small example below

Revenue = 100,000,00

  • Salaries = 60,000.00
  • Extras = 40,000.00
  • But I don’t really know what it would be like to do that.

    Below are the models: 1st Grupodre (would be the totalizers)

    class Grupodre(models.Model):
    master_user = models.ForeignKey('accounts.User', models.CASCADE, verbose_name='Usuario Master')
    num_grupodre = models.IntegerField('Código')
    descricao = models.CharField('Nome Grupo', max_length=20)
    ordem = models.PositiveIntegerField('Ordem no relatório')
    
    class Meta:
        verbose_name = 'Grupo DRE'
        verbose_name_plural = 'Grupos DRE'
        unique_together = [
            ('master_user', 'num_grupodre')
        ]
    
    
    
    def __str__(self):
        return str(self.descricao)
    

    2nd Financial Plan (would refer to the classification of launches)

    class Planofinan(models. Model):

    Scategoria_Choices = (
        (None,'Informe o sinal'),
        ('D', 'Despesas'),
        ('R', 'Receitas'),
    )
    
    
    # informação do dono da conta (usuario Master)
    master_user = models.ForeignKey('accounts.User',models.CASCADE,verbose_name='Usuario Master')
    # dados principais
    num_plfin = models.IntegerField('Código')
    descricao = models.CharField('Descricão',max_length=60)
    sinal = models.CharField('Sinal Conta',max_length=1,choices=Scategoria_Choices)
    grupodre = models.ForeignKey('niluscad.Grupodre',models.SET_NULL,verbose_name='Grupo Dre',null=True,blank=True)
    
    
    class Meta:
        verbose_name = 'Plano Financeiro'
        verbose_name_plural = 'Plano Financeiro'
        unique_together = [
            ('master_user', 'num_plfin')
        ]
    
    
    def __str__(self):
        return self.descricao
    

    3rd Launches (model where it receives the values to total)

    Class Lancamentos(models.Model):
    # informação do dono da conta (usuario Master)
    master_user = models.ForeignKey('accounts.User',models.CASCADE,verbose_name='Usuario Master')
    
    # dados principais (empresa e numero do lançamento)
    num_lan = models.IntegerField('Nº Registro')
    parcela = models.IntegerField('Parcela',default=1)
    company = models.ForeignKey('niluscad.Company',models.CASCADE,verbose_name='Empresa')
    
    
    #dados do titulo
    cadgeral = models.ForeignKey('niluscad.CadGeral',models.CASCADE,verbose_name='Cliente',blank=True,null=True)
    dt_lancamento = models.DateField('Data Lançamento',null=True,blank=True)
    dt_vencimento = models.DateField('Data Vencimento',null=True,blank=True)
    plr_financeiro = models.ForeignKey('niluscad.Planofinan',models.PROTECT,verbose_name='Plano Financeiro')
    conta_finan = models.ForeignKey('nilusfin.Contafinanceira',models.PROTECT,verbose_name='Conta Recebimento')
    c_custo = models.ForeignKey('niluscad.Ccusto',models.PROTECT,verbose_name='Centro de Custo')
    vlr_lancamento = models.DecimalField('Valor do Lançamento',max_digits=13,decimal_places=2,blank=True,null=True)
    valor_text = models.CharField(verbose_name='Valor',  max_length=20)
    saldo = models.DecimalField('Saldo', max_digits=13,decimal_places=2,blank=True,null=True)
    descricao = models.CharField(verbose_name='Observação', max_length=70,null=True,blank=True)
    titulo = models.BooleanField('É Titulo', default=False)
    
    
    #Dados Cotação/Indice
    indice = models.ForeignKey('nilusfin.Indice',models.PROTECT,null=True,blank=True)
    cotacao = models.ForeignKey('nilusfin.Cotacao',models.PROTECT,null=True,blank=True)
    
    
    
    situacao = models.BooleanField('Baixado',default=False)
    reaberto = models.BooleanField('Reaberto',default=False)
    data_baixa = models.DateField('Data de Recebimento',null=True,blank=True)
    lancamento_pai = models.ForeignKey('self',models.SET_NULL,blank=True,null=True,verbose_name='Lançamento Pai')
    
    # Dados Baixa e Situação
    tipoLancto_Choices = (
        ('R', 'Receita'),
        ('D', 'Despesa'),
    )
    
    tipo_lancamento = models.CharField('Tipo', max_length=1, choices=tipoLancto_Choices)
    
    
     class Meta:
        verbose_name = 'Lançamento'
        verbose_name_plural = 'Lançamentos'
        unique_together = [
            ('master_user', 'num_lan','parcela')
        ]
    
    def __str__(self):
         return str(int((self.pk)))
    

    I would like how I can build a View to render in the template as an example above.

    Thank you all for your attention.

    1 answer

    0

    • So my friend, I already took a look, the problem is that UPDATEVIEW takes a record according to the selection parameter within the URL. the problem is that it returns, but it takes too long, I wanted to see if I can get a UPDATEVIEW where the record returns me faster.

    Browser other questions tagged

    You are not signed in. Login or sign up in order to post.