Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

How to do filter or search on JSONField()? #1164

Answered by zbyte64
elcolie asked this question in Q&A
Discussion options

The original is here

If you know the way how to do that please share

You must be logged in to vote

Relevant django-filter issues: carltongibson/django-filter#583 carltongibson/django-filter#426

You can do this by manually defining your own filter, example from the first issue:

MarkaMoto = django_filters.CharFilter(name='attributes', lookup_expr='MarkaMoto__value__contains')

But there are limitations like not supporting icontains or querying arrays.

Replies: 2 comments 1 reply

Comment options

Relevant django-filter issues: carltongibson/django-filter#583 carltongibson/django-filter#426

You can do this by manually defining your own filter, example from the first issue:

MarkaMoto = django_filters.CharFilter(name='attributes', lookup_expr='MarkaMoto__value__contains')

But there are limitations like not supporting icontains or querying arrays.

You must be logged in to vote
0 replies
Answer selected by zbyte64
Comment options

Thank you very much @zbyte64 I though graphene-django has feature to do a generic filter for this problem since it has been around for a year already.

You must be logged in to vote
1 reply
Comment options

zbyte64 Apr 14, 2021
Collaborator

We aren't allowed to have a graphql endpoint with arbitrary keys. For generic filtering, one would have to represent arbitrary key value pairs as it's own input type. The problem looks fairly similar to generic filtering of models across arbitrary columns and has the same concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #697 on April 14, 2021 20:05.

AltStyle によって変換されたページ (->オリジナル) /