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
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',
)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With