Re: [Django] #32059: Issue when counting a model extending auth_user by month

9 views
Skip to first unread message

Django

unread,
Oct 1, 2020, 6:13:35 AM10/1/20
to django-...@googlegroups.com
#32059: Issue when counting a model extending auth_user by month
-------------------------------------+-------------------------------------
Reporter: anderleich | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* status: new => closed
* resolution: => invalid


Comment:

I think you need to `count=Count("month")`, rather than the PK.
([https://docs.djangoproject.com/en/3.1/topics/db/aggregation/ See the
aggregation topic guide.])


Please don't use the issue tracker as a secondary support channel. See
TicketClosingReasons/UseSupportChannels

--
Ticket URL: <https://code.djangoproject.com/ticket/32059#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 1, 2020, 6:37:34 AM10/1/20
to django-...@googlegroups.com
#32059: Issue when counting a model extending auth_user by month
-------------------------------------+-------------------------------------
Reporter: anderleich | Owner: nobody
Type: Bug | Status: closed
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Carlton Gibson):

My comment is too quick.
[https://docs.djangoproject.com/en/3.1/topics/db/aggregation/#values The
use of `values` means the `pk` should work too.].

However, it looks like you've hit the
[https://docs.djangoproject.com/en/3.1/topics/db/aggregation/#interaction-
with-default-ordering-or-order-by default `order_by` issue] below the
linked section there. (Note the `ORDER BY `auth_user`.`date_joined` DESC`
in the SQL.) If you append `.order_by()` clearing the ordering it should
work (as it is testing.)

Hopefully that helps.

--
Ticket URL: <https://code.djangoproject.com/ticket/32059#comment:5>

Reply all
Reply to author
Forward
0 new messages