#26696: QuerySet.extra: group by weekday on a date field
-------------------------------------+-------------------------------------
Reporter: karolyi | Owner: nobody
Type: | Status: closed
Cleanup/optimization |
Component: Database layer | Version: 1.9
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: day of week weekday | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by charettes):
* keywords: QuerySet.extra day of week weekday => day of week weekday
* status: new => closed
* resolution: => invalid
Comment:
Hi Karolyi,
As you can't build the query using `QuerySet.extra()` in the first time
I'm going to close this ticket as ''invalid''. You should be able to
annotate your queryset using `Func(F('datefield'), function='DAYOFWEEK')`
(or `ExtractWeekDay` on Django 1.10+) and use `values()` before your
min/max/avg `annotate()` call to group by your annotated day of week.
Please see
[https://docs.djangoproject.com/en/1.9/topics/db/aggregation/#values the
section about values() in the aggregation docs] for more details and our
[wiki:TicketClosingReasons/UseSupportChannels support channels].
--
Ticket URL: <https://code.djangoproject.com/ticket/26696#comment:2>
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/065.0ac016e560a2c776597e6dfc25c355be%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.