Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e00a5da

Browse files
Fix potential circular import edge-case
Fixes #158
1 parent 4488068 commit e00a5da

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

‎rest_framework_json_api/exceptions.py‎

Lines changed: 7 additions & 1 deletion
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)

AltStyle によって変換されたページ (->オリジナル) /