django rest框架的自定义异常
djangorestframework-custom-exceptions的Python项目详细描述
django rest framework的自定义异常
兼容性
- 使用:
- Python2.7、3.3、3.4
- 危险1.7,1.8
- django rest framework=3.0
安装
从pypi安装包:
pip install djangorestframework-custom-exceptions
在django设置中添加应用程序:
INSTALLED_APPS = ('rest_framework_custom_exceptions',)
配置您的rest框架:
REST_FRAMEWORK = { 'EXCEPTION_HANDLER': 'rest_framework_custom_exceptions.exceptions.simple_error_handler' }
示例
简单的错误处理程序显示如下异常:
{ "error": "Not found" }