Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix potential circular import edge-case
Fixes #158
  • Loading branch information
asteinlein committed Feb 6, 2016
commit e00a5daccf156885bbde434c297bf027f9b403f8
8 changes: 7 additions & 1 deletion rest_framework_json_api/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down