Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- self.get_queryset() \
- .annotate(created_at_date=TruncDate('created_at')) \
- .values('created_at_date') \
- .order_by('created_at_date') \
- .annotate(
- income=ExpressionWrapper((F('items__price') - F('items__product__cost_price'))
- * F('items__total_quantity'),
- output_field=models.DecimalField()),
- total_quantity=Sum('items__total_quantity')) \
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement