diff --git a/api/metadata.py b/api/metadata.py new file mode 100644 index 00000000..4265ecfe --- /dev/null +++ b/api/metadata.py @@ -0,0 +1,16 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +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') + if hasattr(view, 'filter_fields'): + data.update({'filters': view.filter_fields}) + return data diff --git a/babybuddy/settings/base.py b/babybuddy/settings/base.py index ded746c0..5b8935f0 100644 --- a/babybuddy/settings/base.py +++ b/babybuddy/settings/base.py @@ -152,14 +152,15 @@ REST_FRAMEWORK = { 'DEFAULT_FILTER_BACKENDS': [ 'django_filters.rest_framework.DjangoFilterBackend', ], + 'DEFAULT_METADATA_CLASS': 'api.metadata.APIMetadata', + 'DEFAULT_PAGINATION_CLASS': + 'rest_framework.pagination.LimitOffsetPagination', 'DEFAULT_PERMISSION_CLASSES': [ 'api.permissions.BabyBuddyDjangoModelPermissions' ], 'DEFAULT_RENDERER_CLASSES': [ 'rest_framework.renderers.JSONRenderer', ], - 'DEFAULT_PAGINATION_CLASS': - 'rest_framework.pagination.LimitOffsetPagination', 'PAGE_SIZE': 100 }