You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When ValidationError occurs, tastypie responds with an array of errors, that are not seriazlized to JSON correctly.
For example, this is the JSON repsponse, where the array with errors, is python representation of list() object, but not the valid JSON array of strings.
{
"error": "[u'Ticket is already cancelled!']"
}
Expected result would be:
{
"error": [
"Ticket is already cancelled!"
]
}
Thank You.
The text was updated successfully, but these errors were encountered:
sourya
pushed a commit
to sourya/django-tastypie
that referenced
this issue
Oct 18, 2018
We experienced the same error when upgrading our TastyPie codebase to the newest versions: problem is that sanitize function has been introduced there and if you passed a list somewhere in your code, f.e. from form errors ValidationError(form.errors) then this sanitize would break everything. There's no easy way to fix this, since sanitize is implemented as a function.
Our approach was following: we had custom resource implemented, where we re-defined error_response method. Within that method we unpacked back message using html_decode & ast.literal_eval. The second option would be to use custom serializer (because error_response uses serializer methods underneath: serialized = self.serialize(request, errors, desired_format)).
When
ValidationError
occurs, tastypie responds with an array of errors, that are not seriazlized to JSON correctly.For example, this is the JSON repsponse, where the array with errors, is python representation of
list()
object, but not the valid JSON array of strings.Expected result would be:
Thank You.
The text was updated successfully, but these errors were encountered: