This is an extension of the py-buzz package.
It adds extra functionality especially for DRF. Predominately, it adds the ability to jsonify an exception
pip install drf-buzz
Add drf-buzz
exception handler in settings.py
:
REST_FRAMEWORK = {
...
'EXCEPTION_HANDLER': 'drf_buzz.exception_handler'
...
}
Use py-buzz
exceptions in your DRF viewsets:
import drf_buzz
from rest_framework import status, viewsets
class MyException(drf_buzz.DRFBuzz):
status_code = status.BAD_REQUEST
class MyViewSet(viewsets.ViewSet):
def list(self, request):
raise MyException('Not implemented yet.')
To run the test suite execute the following command in package root folder:
python setup.py test