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

时间:2021-03-10 13:08:25   收藏:0   阅读:0
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‘"
}
评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!