Quantità type_1

问题描述 投票:-1回答:1

我有以下情况

Sottocategoria | Quantità
type_1         |  100.00
type_2         |  100.00
type_1         |  100.00

我想获得一个新的表,给我以下的观点。

Sottocategoria | Quantità
type_1         |  200.00
type_2         |  100.00

这里是我的models.py,有 "quantita "和 "sottocategoria "字段的情况。

class Tipologia(models.Model):
    nome= models.CharField('Categoria', max_length=30)

class Sottocategoria(models.Model):
    tipologia = models.ForeignKey(Tipologia, on_delete=models.CASCADE)
    name = models.CharField( max_length=30)

class Materiale(models.Model):
    conto = models.CharField('Conto', max_length=30, choices=(
            ('MATERIA PRIMA', 'MATERIA PRIMA'),
            ('SUSSIDIARIA', 'SUSSIDIARIA'),
        ))
    tipologia = models.ForeignKey(Tipologia, on_delete=models.SET_NULL, null=True)
    sottocategoria = models.ForeignKey(Sottocategoria, on_delete=models.SET_NULL, null=True)
    quantita=models.DecimalField('Quantità',max_digits=5)
django django-models django-rest-framework django-forms django-views
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.