New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filtering ArrayField #473
Comments
django-filter currently doesn't have any filters compatible with the postgres contrib fields - you would need to create your own. It will be more or less difficult depending on what you're trying to do. Supporting the custom lookups for class CharArrayFilter(filters.BaseCSVFilter, filters.CharFilter):
pass
class MyFilterSet(filters.FilterSet):
tags__contains = CharArrayFilter(name='tags', lookup_expr='contains')
class Meta:
model = SomethingTaggable GET http://localhost/api/something-taggable?tags__contains=a,b,c The above filter will validate the comma-separated inputs and return a list of cleaned values, which is suitable for the underlying On the other hand, it's a little more complicated to handle the index and slice transforms, which are unstructured and have a theoretically infinite amount of combinations. |
Thanks for info. |
I'm going to close this as Out of Scope for the moment. Happy to consider documented, tested pull requests. We may have capacity to reconsider in the future. |
Update: class MyFilterSet(filters.FilterSet):
tags__contains = CharArrayFilter(field_name='tags', lookup_expr='contains')
class Meta:
model = SomethingTaggable |
Is it possible to filter fields defined in
django.contrib.postgres.fields
likeArrayField
?The text was updated successfully, but these errors were encountered: