assert False 与 try 结合 在开发中的使用
让错误抛出 发现其中的问题 # coding=utf-8 from rest_framework.views import exception_handler from rest_framework.exceptions import ErrorDetail from share.dj_customer.rest_api_exception import CustomerError def custom_exception_handler(exc, context): # Call REST framework's default exception handler first, # to get the standard error response. .... if isinstance(old_data, dict): if old_data.get('detail') is not None: if isinstance(old_data['detail'], tuple): new_data['code'], new_data['message'] = old_data['detail'][0:2] elif isinstance(old_data['detail'], str): new_data['message'] = old_data['detail'] else