Returning JSON Response Error with custom Renderer #8891
Unanswered
jules-ch
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have an DRF API View that resturn a Dataset in different format (
application/x-netcdf
,'text/csv'
,application/json
).I'm using the standard
Accept
Header to set the desired format.This view accept some query parameters to filter the dataset & validation can throw errors that are handled in the exception handler that returns a DRF
Response
.I want my views to always return errors to be rendered as JSON.
Content-Type
are set asapplication/problem+json
but the response data is then tried to be Rendered with theNetCDFRenderer
if I setAccept
asapplication/x-netcdf
.I have no way to specify the renderer, and I need to return the response as
HTTPResponse
to get around this.The cause is the
finalize_response
function inAPIView
Is there a way to specify the renderer to be used for a response not taking into account the
Accept
Header, for errors, for example.Or do I need to return
HttpRepsonse
in the execption handler.Beta Was this translation helpful? Give feedback.
All reactions