#27812: When there is a DateTimeField django does not group by
-------------------------------------+-------------------------------------
Reporter: Fabio | Owner: nobody
García Sánchez |
Type: Bug | Status: new
Component: Database | Version: 1.10
layer (models, ORM) |
Severity: Normal | Keywords: queryset, group by
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I have 2 models, both have almost the same fields. Just one of them has a
DateTimeField.
The problem comes when I try to group by (not on the DateTimeField) and
summarize using Sum in annotate. The model that does not have the
DateTimeField works properly, the other groups by day, the Sum is per day.
{{{
qs1 =
Bills.objects.values('tipo_documento').annotate(total=Sum('venta_neto'))
print(qs1 )
<QuerySet [{'tipo_documento': 'FV', 'total': Decimal('8419159.0000')},
{'tipo_documento': 'FY', 'total': Decimal('12500000.0000')},
{'tipo_documento': 'FY', 'total': Decimal('210000.0000')}...
}}}
this repeat the type ('tipo_documento'), each Total is per day.
On the other hand, the model without DateTimeField work properly:
{{{
qs2 =
Bills2.objects.values('tipo_documento').annotate(total=Sum('venta_neto'))
print(qs2 )
<QuerySet [{'tipo_documento': 'FV', 'total': Decimal('22367372215.1000')},
{'tipo_documento': 'NV', 'total': Decimal('-38955434.0000')},
{'tipo_documento': 'NI', 'total': Decimal('0.0000')}, {'tipo_documento':
'FY', 'total': Decimal('10155529934.9700')}]>
}}}
qs2 works properly. I have tried to do the same example with another
models and I have got the same issue.
Thanks
--
Ticket URL: <https://code.djangoproject.com/ticket/27812>
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/053.49acf49a481a4d45e62861adf14d5734%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.