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'"
}
posted @ 2021-03-09 19:48  TonyZhang24  阅读(52)  评论(0编辑  收藏  举报