#26010: I need to count objects in a queryset by year and month
-------------------------------------+-------------------------------------
Reporter: Mahmood Khan | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: Queryset.extra | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Rich Rauenzahn):
FYI:
MonthTransform and YearTransform are gone now in Django 1.10.
You can use TruncMonth/TrunchYear from django.db.models.functions.
I believe it is slightly different -- I had to modify my html template to
filter the value through |date: 'Y' and |date: 'm', otherwise I got
something like "2016, midnight" rather than "2016"
See:
http://stackoverflow.com/questions/8746014/django-group-by-date-day-month-
year
https://code.djangoproject.com/ticket/26649
https://docs.djangoproject.com/en/1.10/ref/models/database-
functions/#trunc
--
Ticket URL: <https://code.djangoproject.com/ticket/26010#comment:3>
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/069.bc4b70ca29c62bf087d1a91bc0f4da2e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.