gizmag / drf-ujson-renderer Goto Github PK
View Code? Open in Web Editor NEWDjango Rest Framework renderer using ujson
License: MIT License
Django Rest Framework renderer using ujson
License: MIT License
This is what I'm getting;
{"total_answers":0,"tags":[],"i1":{"t":"http:\/\/localhost:8000\/media\/__sized__\/questions\/1-1545844928\/internal\/i1_disappoint-thumbnail-150x150-70.jpg","f":"http:\/\/localhost:8000\/media\/questions\/1-1545844928\/internal\/i1_disappoint.jpg"}
See the escape of the slashes. Unnecessary. Why is this happening? Am I missing some setting?
I'd like to keep the 'rest_framework.renderers.BrowsableAPIRenderer',
for my app, however, when I use the ujson renderer, the links in the browsable api are no longer clickable.
Am I doing something wrong?
Is this in a fit state to link to from the REST framework docs?
May be worth submitting a PR to the 'third party packages' section of the renderers docs.
https://github.com/tomchristie/django-rest-framework/blob/master/docs/api-guide/renderers.md
e.g. Decimal.decimal("14876279.30")
with standard renderer is represented as 14876279.3
, and with drf-ujson-renderer as 14876279.3000000007
. You need to add 'COERCE_DECIMAL_TO_STRING': False
in your settings to reproduce it.
I'm curios, the drf serializer has a lot of extra code to handle dates, datetimes, timedeltas and other objects, where this one handles none of them. So would this work as a replacement for the default one?
there are several options that can be passed to the ujson calls, e.g.:
encode_html_chars, ensure_ascii, double_precision, escape_forward_slashes, indent
it will be a nice feature to have config where those options can be specified.
I wasn't able to figure out how to add the ujson renderer to the 'DEFAULT_RENDERER_CLASSES'
. Would you mind extending the installation section with more info on how to make ujson the default json library for DRF?
Would you mind updating the PyPI package? It's a bit outdated - it's not including the parser for example.
I don't see any updates for 4 years and a recent PR (#12) hasn't been commented on. I'm just wondering if this package is maintained and safe to use for new projects or if it should be considered dead.
Thanks.
I noticed this being an issue in the past #4, however, it seems it is still causing issues.
The rendering displays the json all on a single line and links are presented as {"user":"http:\/\/127.0.0.1:8000\/user\/"}
Using:
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.