2017-12-06 00:27:28 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
from rest_framework import metadata
|
|
|
|
|
|
|
|
|
|
|
|
class APIMetadata(metadata.SimpleMetadata):
|
|
|
|
"""
|
|
|
|
Custom metadata class for OPTIONS responses.
|
|
|
|
"""
|
|
|
|
def determine_metadata(self, request, view):
|
|
|
|
data = super(APIMetadata, self).determine_metadata(request, view)
|
|
|
|
data.pop('description')
|
2018-08-04 20:00:51 +00:00
|
|
|
if hasattr(view, 'filterset_fields'):
|
|
|
|
data.update({'filters': view.filterset_fields})
|
2021-11-19 16:14:24 +00:00
|
|
|
elif hasattr(view, 'filterset_class'):
|
|
|
|
data.update({'filters': view.filterset_class.Meta.fields})
|
2017-12-06 00:27:28 +00:00
|
|
|
return data
|