drf_orjson_render 1.4.0 fail.
falsetru opened this issue · 0 comments
falsetru commented
My application breaks after upgrading to drf_orjson_render 1.4.0
ERROR django.request:log.py:224 Internal Server Error: /path-replaced/97336477996045/55391693115234
Traceback (most recent call last):
File "/home/falsetru/.virtualenvs/project-name-replaced/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/falsetru/.virtualenvs/project-name-replaced/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/falsetru/work/project-name-replaced-project/targetyo/util/db.py", line 53, in inner
return f(*args, **kwargs)
File "/home/falsetru/work/project-name-replaced-project/targetyo/api/decorators.py", line 36, in wrapper
return func(request, *args, **kwargs)
File "/home/falsetru/.virtualenvs/project-name-replaced/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/home/falsetru/.virtualenvs/project-name-replaced/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/home/falsetru/.virtualenvs/project-name-replaced/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/home/falsetru/.virtualenvs/project-name-replaced/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/home/falsetru/.virtualenvs/project-name-replaced/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/home/falsetru/.virtualenvs/project-name-replaced/lib/python3.8/site-packages/rest_framework/views.py", line 497, in dispatch
self.initial(request, *args, **kwargs)
File "/home/falsetru/.virtualenvs/project-name-replaced/lib/python3.8/site-packages/rest_framework/views.py", line 406, in initial
neg = self.perform_content_negotiation(request)
File "/home/falsetru/.virtualenvs/project-name-replaced/lib/python3.8/site-packages/rest_framework/views.py", line 310, in perform_content_negotiation
return conneg.select_renderer(request, renderers, self.format_kwarg)
File "/home/falsetru/.virtualenvs/project-name-replaced/lib/python3.8/site-packages/rest_framework/negotiation.py", line 65, in select_renderer
full_media_type = ';'.join(
TypeError: sequence item 0: expected str instance, NoneType found
I think this is caused by ORJSONRenderer.media_type
change in 9dddb21#diff-af3668e3a8a4fd6a0dcb9a8d9a2550ac2f7fb3e562e2f5f94be73b28b0770684L21
In 1.3:
>>> from drf_orjson_renderer.renderers import ORJSONRenderer
>>> ORJSONRenderer.media_type
'application/json'
In 1.4:
>>> from drf_orjson_renderer.renderers import ORJSONRenderer
>>> ORJSONRenderer.media_type # None
>>>
Packages used:
- Django==3.2.10
- djangorestframework==3.12.4
- drf-orjson-renderer==1.4.0
REST_FRAMEWORK:
REST_FRAMEWORK = {
"DEFAULT_RENDERER_CLASSES": [
"drf_orjson_renderer.renderers.ORJSONRenderer",
"rest_framework.renderers.BrowsableAPIRenderer",
],
"TIME_FORMAT": "%H:%M:%S",
}