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

UJSONRenderer breaks rest_framework.renderers.BrowsableAPIRenderer #4

Open
robbyt opened this issue Mar 4, 2015 · 3 comments
Open

Comments

@robbyt
Copy link

robbyt commented Mar 4, 2015

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?

@jacobh
Copy link
Contributor

jacobh commented Mar 6, 2015

Hi, this issue is the first I've heard of issues between the two renderers, and I don't see how the would interfere with each other, very strange.

I haven't got time to investigate this myself, however if you find that this is a bug in drf-ujson-renderer I'll happily accept a pull request.

@JockeTF
Copy link

JockeTF commented Aug 17, 2015

I've reported this to Django REST framework.

encode/django-rest-framework#3283

@mitar
Copy link

mitar commented Mar 13, 2016

I fixed this with the following workaround:

from drf_ujson import renderers

class JSONRenderer(renderers.UJSONRenderer):
    def render(self, data, accepted_media_type=None, renderer_context=None):
        if renderer_context.get('indent', None):
            return super(renderers.UJSONRenderer, self).render(data, accepted_media_type, renderer_context)
        else:
            return super(JSONRenderer, self).render(data, accepted_media_type, renderer_context)

(In my fork UJSONRenderer extends JSONRenderer, so super above works.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants