#28650: Add TruncWeek
-------------------------------------+-------------------------------------
Reporter: Sigurd | Owner: nobody
Ljødal |
Type: New | Status: new
feature |
Component: Database | Version: master
layer (models, ORM) |
Severity: Normal | Keywords: ORM Extract
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Add `TruncWeek` class to truncate date/datetime fields to midnight at the
monday of the week. This is useful to e.g. group values by week.
{{{
from django.db.models.functions import TruncWeek
SomeModel.objects.annotate(
monday_of_week=TruncWeek('some_date'),
).values(
'monday_of_week',
).annotate(
sum=Sum('some_field'),
)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28650>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" 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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/049.7b27d01d4040645fcb0f3f6bfd80adf5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.