Django & postgresql arrayfield support + filtering objects based on array contents

95 views
Skip to first unread message

zayatzz

unread,
Sep 3, 2012, 8:15:11 AM9/3/12
to django...@googlegroups.com
Hello

About a year ago i found this :


and developed upon it (https://github.com/zay2/django-arrayfields) and integrated it into my project. Now i know that in postgresql i can do something like this:

    SELECT * FROM sal_emp WHERE 10000 = ANY (pay_by_quarter);

where pay_by_quarter is arrayfield, to select rows by value in arrayfield. But since django does not offer postgresql arrayfields support im quite sure it does not support filtering based on arrayfield contents. 

But still i would like to be able to do just that in my project - so what should i extend now? Queryset filter method or rather query_utils.Q class? Or should i even bother since this arrayfield can be looked up as string and its contents can be searched like queryset.filter(fieldname_icontains='something') or should i rather use raw query there?

what do you think?

Alan
Message has been deleted

Axel Rau

unread,
Sep 3, 2012, 12:29:33 PM9/3/12
to django...@googlegroups.com

Am 03.09.2012 um 14:15 schrieb zayatzz:

> But since django does not offer postgresql arrayfields support
Jonathan S. Katz implemented a library of Django extensions for PosgreSQL and wrote an excellent presentation:
http://wiki.postgresql.org/images/e/e6/Django-extensions.pdf
https://github.com/jkatz/django_postgres_extensions
It contains integer array support.

Axel
---
PGP-Key:29E99DD6 ☀ +49 151 2300 9283 ☀ computing @ chaos claudius

Reply all
Reply to author
Forward
0 new messages