更新时间:2023-12-04 09:34:58
提出一个 ValidationError
,我只会提出一个 ParseError 或适合错误描述的其他自定义错误:
Rather than raising a ValidationError
, I will just raise a ParseError or another custom error that fits the error description:
from rest_framework import exceptions
def pre_delete(self, obj):
if obj.survey:
raise exceptions.ParseError("Too late to delete")