Reputation: 1128
Is there any way to allow Django app to accept the custom accept header like "application/vdn.name.v1+json"?
I keep getting a response like this
Could not satisfy the request Accept header.
I am using Django Rest Framework as well
Upvotes: 7
Views: 7824
Reputation: 308779
Try defining a custom renderer and setting the media_type
attribute.
from rest_framework.renderers import JSONRenderer
class MyRenderer(JSONRenderer):
media_type = 'application/vdn.name.v1+json'
Then enable your renderer (see the docs for more info)
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'path.to.MyRenderer',
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',
)
}
Upvotes: 6