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

JSONField not rendered properly in DRF browsable API HTML form #4999

5 of 6 tasks
hommel opened this issue Mar 17, 2017 · 2 comments
5 of 6 tasks

JSONField not rendered properly in DRF browsable API HTML form #4999

hommel opened this issue Mar 17, 2017 · 2 comments


Copy link

@hommel hommel commented Mar 17, 2017


  • I have verified that that issue exists against the master branch of Django REST framework.
  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
    • #4135: webform-input parsed as string (PR: #4565)
  • This is not a usage question. (Those should be directed to the discussion group instead.)
  • This cannot be dealt with as a third party library. (We prefer new functionality to be in the form of third party libraries where possible.)
  • I have reduced the issue to the simplest possible case.
  • I have included a failing test as a pull request. (If you are unable to do so we can still accept the issue.)

Expected behavior


  • a valid JSON object is stored in postgreSQL as a django models.JSONField and
  • that data is serialized using DRF's serializers.JSONField,

then that data should render as a JSON object in DRF browsable API (particularly because the serializer requires input to be valid JSON for POST/PUT/PATCH methods)

Actual behavior

Data renders as native python in DRF browsable API form field (e.g. single quotes, uppercase booleans)


Note that the "Raw data" view of the input section renders the data correctly as JSON.


Steps to reproduce

(venv)vagrant@vm:/vagrant/src/app$ python -V
Python 3.4.3
(venv)vagrant@vm:/vagrant/src/app$ psql -V
psql (PostgreSQL) 9.6.2
# requirements.txt

from django.db import models
from django.contrib.postgres.fields import JSONField

class Foo(models.Model):

    name = models.CharField(max_length=24)
    data = JSONField()

from rest_framework import serializers

from jsontest import models

class FooSerializer(serializers.HyperlinkedModelSerializer):

    name = serializers.CharField(max_length=24)
    data = serializers.JSONField()

    class Meta:
        model = models.Foo
        fields = ('url', 'name', 'data')
>>> from jsontest.models import *
>>> f = Foo()
>>> = 'created via shell'
>>> = {'input': 'native dict', 'bar': True}
@xordoquy xordoquy added the Bug label Mar 18, 2017
Copy link

@xordoquy xordoquy commented Mar 18, 2017

Thanks for reporting.
I gave it a try and yeah, this is reproduced.

tomchristie added a commit that referenced this issue Apr 27, 2017
PoC Add JSONBoundField to serializers (Fixes #4999)
Copy link

@aleehedl aleehedl commented Sep 25, 2018

I'm still experiencing this bug.
Edit: issue #6211 is separate but related.


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

No branches or pull requests

3 participants