For example, I have a simple django-model:
class SimpleModel(models.Model):
some_attr = models.JSONField() #there is [attr1, attr2, ...] in JSON
Simple view:
class SimpleView(ListCreateApivView):
filter_backends = [DjangoFilterBackend, ]
filterset_class = SimpleFilter
And simple filter:
class SimpleFilter(django_filters.FilterSet):
class Meta:
model = SimpleModel
fields = {'some_attr': ['icontains', ]}
I wanna check is the http://127.0.0.1/simple?some_attr__icontains=['Something, that I have in db'] In my db there is JSONField, which contains [a1, a2, a3 ...], so, how can I check is value from url is in db JSONField?
Thanks for answer, I solve the problem with creating custom-filter for my JSON-field, something like that: