Django REST Exceptions

后端 未结 2 887
谎友^
谎友^ 2021-01-30 13:58

I currently have some code for a view based on the Django REST Framework. Ive been using a customer exception class, but ideally I want to use the inbuilt Django REST exceptions

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-30 14:48

    You can use the build in DRF exception, just import and raise

    from rest_framework.exceptions import
    ...
    raise ParseError('I already have a status code!')
    

提交回复
热议问题