I'm doing a similar thing. I'm receiving GETs in which the Accept-headers aren't correct, either. Based on the parameters I receive, I am transforming string data into various chemical data types or images. I have custom renderers to handle the data types I am using. In my view, I am attempted to set the accepted_renderer to the correct renderer. I have tried setting accepted_renderer on the request and the response without success. My results still come back as JSON.
Code snippets
------------------------------------
In renderers.py
class MolRenderer(BaseRenderer):
media_type = 'chemical/x-mdl-molfile'
format = 'mol'
def render(self, data, accepted_media_type=None, renderer_context=None):
return data
----------------------------------------
In my view:
if serializer.data['output_type'] == 'mol':
request.accepted_renderer = MolRenderer()
-------------
I know this has to do with content negotiation, but, I'm not keen to write my own content negotiation unless absolutely necessary.
Thanks for any advice/help.
-Joann