我有一个例外,这使我的错误,从形式像::Python的验证错误的对象不是JSON序列化
except ValidationError as e:
return JsonResponse(e, safe=False)
据giveing我的错误 ValidationError({'age': [u'This field is required.'], 'name': [u'This field is required.']}) is not JSON serializable
为什么我得到这个错误,我怎么能使它工作..任何想法?
?请尝试显示[mcve] – Sayse
@Sayse我张贴从窗体ajax,所以我想发送错误作为回应.. – gamer
不知道你为什么 - - 我。但Sayse的观点仍然有效。表单将验证错误收集到一个错误列表中,这就是你应该序列化。在任何情况下,都不要从表单方法中返回响应。 –