mirror of https://github.com/snachodog/mybuddy.git
Add a custom API metadata class to include filters on OPTIONS responses.
This commit is contained in:
parent
26a3c1c721
commit
9e220d29f4
|
@ -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
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue