amertz08 / drf_ujson2 Goto Github PK
View Code? Open in Web Editor NEWJSON parser and renderer using ujson for Django Rest Framework
License: MIT License
JSON parser and renderer using ujson for Django Rest Framework
License: MIT License
Looks like usjon 3.0 dropped. Need to make sure it is fully supported.
https://github.com/ultrajson/ultrajson/releases/tag/3.0.0
Currently the link redirects to https://github.com/Amertz08/drf-ujson2
and this address does not exist (404).
The link should redirect to https://github.com/Amertz08/drf_ujson2
it would be great to fix it to easily access the repository from the pypi drf-ujson2 site.
ujson 2.0.0 has removed double_precision
and precise_float
so this lib crashes now.
https://github.com/ultrajson/ultrajson/releases/tag/2.0.0
ultrajson/ultrajson@eb7d894
Not sure why, but can't use this library together with https://github.com/Tivix/django-rest-auth or later fork https://github.com/jazzband/dj-rest-auth. Keep getting errors of this type for all responses: TypeError: 'Password has been reset with the new password.' is not JSON serializable
Hello,
within a Pretix deployment in our team, we had issues with incompatible versions of ujson
and drf_ujson
.
This library (drf_ujson2
) uses the default
parameter from ujson
in renderers.py#L44
. This parameter is introduced in version 4.2.0 of ujson
. However, drf_ujson2
only enforces ujson>=2.0.1
as dependency.
From my point of view, we should change this dependency to at least ujson>=4.2.0
. Are there any objections against this proposal?
Hi!
Plain ujson is dead upstream and fails to import due to link errors with recent Python, e.g. 3.7. I have been looking out for ujson-based alternatives and documented my findings at python-rapidjson/python-rapidjson#130 (comment) .
Out of those only ujson-segfault seems like an option to me. There is also resurrection happening at https://github.com/ultrajson/ultrajson-fork starting off ultrajson/ultrajson#343 (comment) but the code is not on PyPI yet, to my best knowledge.
Best, Sebastian
hi
Could you please publish package on Anaconda cloud anaconda.org for conda users ?
Thank you.
Photo
objects throw TypeError when using UJSONRenderer>>> p = Photo.objects.all()[0]
>>> p
<Photo: LE123: Photo_L*>
>>> s = PhotoSerializer(p)
>>> s.data
{'id': 4875, 'name': 'LE123 Photo_L.jpg', 'image': '/images/LE123_Photo_L.jpg', 'product': UUID('ffdce82f-f094-499a-b221-2b49ec9c36ff')}
>>> UJSONRenderer().render(s.data)
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/drf_ujson/renderers.py", line 42, in render
indent=indent or 0,
TypeError: �1a-�� is not JSON serializable
>>> from rest_framework.renderers import JSONRenderer
>>> JSONRenderer().render(s.data)
b'{"id":4875,"name":"LE123 Photo_L.jpg","image":"/images/LE123_Photo_L.jpg","product":"ffdce82f-f094-499a-b221-2b49ec9c36ff"}'
class Category(OrderedModel):
category = models.CharField(max_length=50)
order = models.PositiveIntegerField(_("order"), editable=False, db_index=True)
class Product(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
...
category = models.ManyToManyField(Category)
class Photo(models.Model):
name = models.CharField(max_length=500, null=True)
image = models.ImageField(null=True)
product = models.ForeignKey(Product, on_delete=models.SET_NULL, null=True)
class PhotoSerializer(serializers.ModelSerializer):
class Meta:
model = Photo
fields = "__all__"
class ProdSerializer(serializers.ModelSerializer):
category = serializers.StringRelatedField(many=True)
photo_set = PhotoSerializer(many=True)
class Meta:
model = Product
fields = "__all__"
class CategorySerializer(serializers.ModelSerializer):
class Meta:
model = Category
fields = "__all__"
Photo
object?Is repo alive and maintained?
Hi!
I think the JSON decoding part is at least as interesting as the encoding part (because it's faster and rejects single surrogates as invalid). So it's great you move off drf-ujson-renderer
for a name. However the descriptions have not caught up yet: On the GitHub repo, on PyPI and in the readme. I propose these changes:
--- Django Rest Framework UJSON Renderer
+++ Django Rest Framework UJSON Parser and Renderer
--- Django Rest Framework renderer using ujson
+++ Django Rest Framework JSON parser and renderer using ujson
--- New repo for forked from https://github.com/Amertz08/drf-ujson-renderer
+++ JSON parser and renderer using ujson for Django Rest Framework
PS: This page I created today may be of interest: https://djangopackages.org/grids/g/drf-json-decoder-integration/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.