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.
|
|
|
|
"""
|
2022-02-10 00:00:30 +00:00
|
|
|
|
2017-12-06 00:27:28 +00:00
|
|
|
def determine_metadata(self, request, view):
|
|
|
|
data = super(APIMetadata, self).determine_metadata(request, view)
|
2022-02-10 00:00:30 +00:00
|
|
|
data.pop("description")
|
|
|
|
if hasattr(view, "filterset_fields"):
|
|
|
|
data.update({"filters": view.filterset_fields})
|
|
|
|
elif hasattr(view, "filterset_class"):
|
|
|
|
data.update({"filters": view.filterset_class.Meta.fields})
|
2017-12-06 00:27:28 +00:00
|
|
|
return data
|