|
2 | 2 | from django.utils import six, encoding
|
3 | 3 | from django.utils.translation import ugettext_lazy as _
|
4 | 4 | from rest_framework import status, exceptions
|
5 | | -from rest_framework.views import exception_handler as drf_exception_handler |
6 | 5 |
|
7 | 6 | from rest_framework_json_api.utils import format_value
|
8 | 7 |
|
9 | 8 |
|
10 | 9 | 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 |
11 | 17 | response = drf_exception_handler(exc, context)
|
12 | 18 |
|
13 | 19 | if not response:
|
|
0 commit comments