diff --git a/rest_framework_json_api/exceptions.py b/rest_framework_json_api/exceptions.py index 1e976dfe..935fecdb 100644 --- a/rest_framework_json_api/exceptions.py +++ b/rest_framework_json_api/exceptions.py @@ -2,12 +2,18 @@ from django.utils import six, encoding from django.utils.translation import ugettext_lazy as _ from rest_framework import status, exceptions -from rest_framework.views import exception_handler as drf_exception_handler from rest_framework_json_api.utils import format_value def exception_handler(exc, context): + # Import this here to avoid potential edge-case circular imports, which + # crashes with: + # "ImportError: Could not import 'rest_framework_json_api.parsers.JSONParser' for API setting + # 'DEFAULT_PARSER_CLASSES'. ImportError: cannot import name 'exceptions'.'" + # + # Also see: https://github.com/django-json-api/django-rest-framework-json-api/issues/158 + from rest_framework.views import exception_handler as drf_exception_handler response = drf_exception_handler(exc, context) if not response: