From a716b282351db4de159efa251f040e768465ae04 Mon Sep 17 00:00:00 2001 From: Alexei Ardyakov Date: Wed, 11 Sep 2019 15:56:21 +0300 Subject: [PATCH] Allow to specify JSONField and HStoreField lookup paths in search_fields --- rest_framework/filters.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rest_framework/filters.py b/rest_framework/filters.py index c15723ec3..d8de81d55 100644 --- a/rest_framework/filters.py +++ b/rest_framework/filters.py @@ -90,6 +90,9 @@ class SearchFilter(BaseFilterBackend): parts = search_field.split(LOOKUP_SEP) for part in parts: field = opts.get_field(part) + if field.get_internal_type() in ('JSONField', 'HStoreField'): + # These fields support arbitrary key lookups + break if hasattr(field, 'get_path_info'): # This field is a relation, update opts to follow the relation path_info = field.get_path_info()