Monday, September 3, 2012

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

Hello

About a year ago i found this :

https://github.com/aino/django-arrayfields

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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/ZeXZoa5pShAJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment