Horje
Group by date (day, month, year) Code Example
Group by date (day, month, year)
from django.db.models.functions import TruncMonth
from django.db.models import Count

Sales.objects
    .annotate(month=TruncMonth('created'))  # Truncate to month and add to select list
    .values('month')                          # Group By month
    .annotate(c=Count('id'))                  # Select the count of the grouping
    .values('month', 'c')                     # (might be redundant, haven't tested) select month and count




Python

Related
solving differential equations in python Code Example solving differential equations in python Code Example
howmanydays python Code Example howmanydays python Code Example
matrix outer product python Code Example matrix outer product python Code Example
python variable Code Example python variable Code Example
run python test in terminal Code Example run python test in terminal Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6