From 64257823c507d8eaea5c09513bc8a910cb69b0bc Mon Sep 17 00:00:00 2001 From: ibuler Date: Wed, 13 Jan 2021 18:02:03 +0800 Subject: [PATCH] =?UTF-8?q?pref(common):=20=E4=BC=98=E5=8C=96drf=20options?= =?UTF-8?q?=E7=9A=84filterset=20=E5=8F=AF=E8=83=BD=E5=BC=95=E8=B5=B7?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/drf/metadata.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/common/drf/metadata.py b/apps/common/drf/metadata.py index 97a42acc0..eda1dd561 100644 --- a/apps/common/drf/metadata.py +++ b/apps/common/drf/metadata.py @@ -92,6 +92,13 @@ class SimpleMetadataWithFilters(SimpleMetadata): fields = view.get_filter_fields(request) elif hasattr(view, 'filter_fields'): fields = view.filter_fields + elif hasattr(view, 'filterset_fields'): + fields = view.filterset_fields + elif hasattr(view, 'get_filterset_fields'): + fields = view.get_filterset_fields(request) + + if isinstance(fields, dict): + fields = list(fields.keys()) return fields def get_ordering_fields(self, request, view):