#34444: Summing through a One-to-Many relationship on the property of a
JSONField
fails
-------------------------------------+-------------------------------------
Reporter: Clément Escolano | Owner: nobody
Type: Bug | Status: new
Component: Database layer | Version: 4.1
(models, ORM) |
Severity: Normal | Resolution:
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 Clément Escolano):
OK, sorry for the trouble, I found a solution which is casting the
annotated field to `DecimalField`:
{{{
groups =
Group.objects.annotate(total=Cast(Sum("memberships__extra__amount"),
output_field=DecimalField()).all()
groups[0].total
}}}
I don't know if this is normal behaviour to require casting but I guess
this is OK for me
--
Ticket URL: <https://code.djangoproject.com/ticket/34444#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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/010701872a704209-5c69ca21-ca5b-493d-8012-e1d6618ebc2c-000000%40eu-central-1.amazonses.com.