Browse Source

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

pull/5415/head
ibuler 4 years ago committed by Jiangjie.Bai
parent
commit
64257823c5
  1. 7
      apps/common/drf/metadata.py

7
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):

Loading…
Cancel
Save