PoC Add JSONBoundField to serializers (Fixes #4999)#5042
PoC Add JSONBoundField to serializers (Fixes #4999)#5042lovelydinosaur merged 3 commits intoencode:masterfrom boxingwizards:i4999
Conversation
|
Looks good to me. Need to think a bit about how this plays with the |
|
|
||
| class JSONBoundField(BoundField): | ||
| def as_form_field(self): | ||
| value = json.dumps(self.value) |
There was a problem hiding this comment.
Does this display in a textarea or an input? Ideally an indented style and a textarea would probably be nice.
There was a problem hiding this comment.
That's a good point. Right now it does input, but I can see if I can make it do indented + textarea.
|
This does seem pretty valid, yup. |
|
I'm going to be out of the office until Apr. 22, and I've been trying to wrap some other stuff up before I go, so this has gotten pushed down the priority queue. I'll take it up again when I get back. |
|
I've updated my branch, I think addressing everybody's feedback so far. The updated code should play nicely with binary=True, although additional testing from someone who uses binary would be helpful. I've also changed the form to use a text area and indent the JSON. |
|
Nice improvement that, thanks! |
Per issue #4999, JSONFields are not rendered properly in the DRF
browsable API HTML forms. This patch attempts to fix that behavior by
introducing a JSONBoundField helper similar to the NestedBoundField
helper.
Description
I experienced #4999 today and put together this patch as an attempt to fix it. I'd appreciate any feedback as to whether this approach makes sense as this is my first dive into the DRF code. I could particularly use some guidance on what tests, documentation, etc. I should add.
./runtests.py reports all tests pass. tox reports failures in py35-djangomaster and py36-djangomaster, but those are present in my environment without this patch also. All other tox tests pass.