Iv'e got a custom object-level validator in one of my serializers:
def validate(self, data):
# some checks on token
# set token to True or False
if not token:
raise serializers.ValidationError(
{
"status": "failed",
"message": _("token is not valid"),
}
)
return data
What I expect to get as an output is this:
{
"status": "failed",
"message": "token is not valid"
}
However, what I'm actually getting is:
{
"status": [
"failed"
],
"message": [
"token is not valid"
]
}
Is there anyway to achieve what I'm looking for?