Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removes DjangoNumpyJSONEncoder (breaking change) #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
20 changes: 0 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,5 @@ order to take advantage of the RestFramework Browsable API, when the
requested media type is not `application/json`, the ORJSON renderer will add
`orjson.OPT_INDENT_2` to the options mask to pretty print your output.

## Numpy

When this package was originally written ORJSON did not natively support
serializing numpy types. This package provided an encoder class that
overrides the DjangoJSONEncoder with support for numpy types. This encoder
is no longer necessary but included for backwards compatibility.

```Python
from drf_orjson_renderer.encoders import DjangoNumpyJSONEncoder
from rest_framework.views import APIView

class MyView(APIView):


def get_renderer_context(self):
renderer_context = super().get_renderer_context()
renderer_context["django_encoder_class"] = DjangoNumpyJSONEncoder
return renderer_context
```

## Benchmarks
See the [orjson Benchmarks](https://github.com/ijl/orjson#performance) for more information
30 changes: 0 additions & 30 deletions drf_orjson_renderer/encoders.py

This file was deleted.

2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Django>=3.2
djangorestframework>=3.9
orjson>=2.4
orjson>=3.3
3 changes: 0 additions & 3 deletions tests/test_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from rest_framework.settings import api_settings
from rest_framework.utils.serializer_helpers import ReturnDict, ReturnList

from drf_orjson_renderer.encoders import DjangoNumpyJSONEncoder
from drf_orjson_renderer.parsers import ORJSONParser
from drf_orjson_renderer.renderers import ORJSONRenderer

Expand Down Expand Up @@ -284,7 +283,6 @@ def test_built_in_renderer_works_correctly_with_numpy_int(self):
rendered = self.renderer.render(
data=data,
media_type="text/html",
renderer_context={"django_encoder_class": DjangoNumpyJSONEncoder,},
)
reloaded = orjson.loads(rendered)

Expand All @@ -299,7 +297,6 @@ def test_built_in_renderer_works_correctly_with_numpy_floating(self):
rendered = self.renderer.render(
data=data,
media_type="text/html",
renderer_context={"django_encoder_class": DjangoNumpyJSONEncoder,},
)
reloaded = orjson.loads(rendered)

Expand Down