2👍
The errors you receive from your backend aren’t JSON API conform errors.
You have to transform the errors in a custom serializer’s extractErrors
method (see the RESTSerializer documentation for an example) or you change the backend to return JSON API conform errors.
An example of multiple errors conform to the JSON API
spec:
{
"errors": [
{
"status": "403",
"source": { "pointer": "/data/attributes/secret-powers" },
"detail": "Editing secret powers is not authorized on Sundays."
},
{
"status": "422",
"source": { "pointer": "/data/attributes/volume" },
"detail": "Volume does not, in fact, go to 11."
},
{
"status": "500",
"source": { "pointer": "/data/attributes/reputation" },
"title": "The backend responded with an error",
"detail": "Reputation service not responding after three requests."
}
]
}
0👍
Going through the code I found that this setting is needed on the django side:
REST_FRAMEWORK = {
...
'EXCEPTION_HANDLER': 'rest_framework_json_api.exceptions.exception_handler',
...
}
- [Answered ]-Django – How to move attribute to another model and delete it
- [Answered ]-Is there a way to have dictinary-like field in Django model?
- [Answered ]-Static js doesn't load — Django
- [Answered ]-How do I merge two django db's?
- [Answered ]-Django get model with foreign key
Source:stackexchange.com