pref(common): 优化drf options的filterset 可能引起的问题

pull/5415/head
ibuler 2021-01-13 18:02:03 +08:00 committed by Jiangjie.Bai
parent a7468a243d
commit 64257823c5
1 changed files with 7 additions and 0 deletions

View File

@ -92,6 +92,13 @@ class SimpleMetadataWithFilters(SimpleMetadata):
fields = view.get_filter_fields(request) fields = view.get_filter_fields(request)
elif hasattr(view, 'filter_fields'): elif hasattr(view, 'filter_fields'):
fields = 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 return fields
def get_ordering_fields(self, request, view): def get_ordering_fields(self, request, view):