DJANGO Rendering one FOR within another

0

I have a situation that is as follows:

I need to do in one html TableA where I have to show the totals and line and the values that make up this totalizer, as a small example below

Recipes = 100,000.00    

  • Salaries = 60,000.00
  •    
  • Extras = 40,000.00
  • But I'm not really sure how to do it.

    Below are the models: 1st GroupDre (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 the launches)

    class PlanFinan (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 totalize)

    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 to mount a View to render the template as shown above.

    Thank you all for your attention.

        
    asked by anonymous 14.03.2018 / 02:56

    1 answer

    0

    Take a look at the documentation that it can be better than the answers in this community. You may want to read the documentation to understand the roots of Django.

    link

        
    14.03.2018 / 13:35