Yes, there is.
You can implement your renderer and add it to your settings.py like this :
REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': (
'< your renderer >',
),
}
And for the actual renderer - take inspiration from the rest_framework's JSON renderer ( rest_framework.renderers.JSONRenderer ).
You can basically take the implementation of this JSONRenderer and change render function slightly.
def render(self, data, accepted_media_type=None, renderer_context=None):
"""
Render `data` into JSON, returning a bytestring.
"""
Here you will have access to data and renderer_context. The context has response object which is your response. It has 'status_code' attribute which you can use in your response.
response = renderer_context['response']
my_response = { "status" : response.status_code,
"message" : "OK",
"content" : data }
For the message, it is up to you where you get correct message for given status code.
Then, if you follow the original JSONRendener implementation, you can find the following snippet and you can just change it to dump your new response:
ret = json.dumps(
my_response, cls=self.encoder_class,
indent=indent, ensure_ascii=self.ensure_ascii,
allow_nan=not self.strict, separators=separators
)