I'm using django 1.9 with its built-in JSONField and postgres 9.4. In my 
model's attrs json field I store objects with some values, including 
numbers. And I need to aggregate over them to find min/max values. 
Something like this:

Model.objects.filter(**some).aggregate(min=Min('attrs__my_key'))

Also it would be useful to extract specific keys:

Model.objects.filter(**some).values_list('attrs__my_key', flat=True)

The above queries fail with FieldError: "Cannot resolve keyword 'my_key' 
into field. Join on 'attrs' not permitted."

Is it possible somehow?
I've started to dig into query expressions but without any success yet.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d29bcc75-0879-4516-b831-f7aed79e1a98%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to