Using it as `qs.annotate(num_items=models.Sum("jsonfield__arraylen"))`
results in the query fragment:
{{{
SELECT SUM("model"."jsonfield") AS "num_items"
}}}
i.e. the `arraylen` lookup is ignored/not done.
`qs.values("jsonfield__arraylen")` works as expected.
Modifying it to `models.Sum(JsonbArrayLength("jsonfield"))` gives the
desired result.
--
Ticket URL: <https://code.djangoproject.com/ticket/31469>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* type: Bug => New feature
* resolution: => duplicate
Comment:
Aggregates doesn't respect lookups, it's not related with a custom
implementation or with `JSONField`'s.
Duplicate of #25534.
--
Ticket URL: <https://code.djangoproject.com/ticket/31469#comment:1>