Django RestFrameWork query list 1接口返回异常信息f

from rest_framework.exceptions import ValidationError
# ...
        raise ValidationError(detail="size must be either 'large' or 'small'")

  

DRF catches these exceptions and displays them neatly. It returns a JSON of the form

{
    "detail": "size must be either 'large' or 'small'"
}
原文地址:https://www.cnblogs.com/atuotuo/p/14507683.html