Hi to everyone:
Having models like these:
class Area(models.Model):
name = models.CharField(max_lentgh=30)
class Element(models.Model):
name = models.CharField(max_lentgh=30)
class Expenses(models.Model):
area = models.ForeignKey(Area, on_delete=models.CASCADE )
element = models.ForeignKey(Element, on_delete=models.CASCADE )
year = models.SmallIntegerField()
month = models.SmallIntegerField()
cost = model.DecimalField(max_digits=10, decimal_places=2, default=0)
I would like to group by area, then by element, and then get sum by month
and accumulated expenses for that element in the year. how could that be
done using Django ORM?
Something to show like this
Expenses in current
Area Element Month Year
Operations Cell phone 325.65 712.40
Operations Office consumibles 451.00 1028.56
Main office Cell phone 148.89 284.41
Main office Office consumibles 650.00 1300.00
Thanks in advance,
Felix.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/001001d4cecd%240b53dd10%2421fb9730%24%40epepm.cupet.cu.
For more options, visit https://groups.google.com/d/optout.