Skip to content

Commit c37d3f4

Browse files
committed
Merge pull request #201 from asteinlein/develop
Fix potential circular import edge-case
2 parents 4488068 + e00a5da commit c37d3f4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

rest_framework_json_api/exceptions.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
from django.utils import six, encoding
33
from django.utils.translation import ugettext_lazy as _
44
from rest_framework import status, exceptions
5-
from rest_framework.views import exception_handler as drf_exception_handler
65

76
from rest_framework_json_api.utils import format_value
87

98

109
def exception_handler(exc, context):
10+
# Import this here to avoid potential edge-case circular imports, which
11+
# crashes with:
12+
# "ImportError: Could not import 'rest_framework_json_api.parsers.JSONParser' for API setting
13+
# 'DEFAULT_PARSER_CLASSES'. ImportError: cannot import name 'exceptions'.'"
14+
#
15+
# Also see: https://github.com/django-json-api/django-rest-framework-json-api/issues/158
16+
from rest_framework.views import exception_handler as drf_exception_handler
1117
response = drf_exception_handler(exc, context)
1218

1319
if not response:

0 commit comments

Comments
 (0)