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'"
}

相关文章:

  • 2022-12-23
  • 2021-12-11
  • 2021-11-12
  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2021-06-14
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-04-04
  • 2021-11-09
  • 2021-05-16
  • 2022-12-23
  • 2021-12-28
相关资源
相似解决方案