Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-rest-framework
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
django-rest-framework
Commits
7a0bd1c4
Commit
7a0bd1c4
authored
Apr 26, 2017
by
Dave Allan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use text area for JSON fields and indent JSON
parent
11d8e4df
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
3 deletions
+3
-3
rest_framework/utils/field_mapping.py
+2
-2
rest_framework/utils/serializer_helpers.py
+1
-1
No files found.
rest_framework/utils/field_mapping.py
View file @
7a0bd1c4
...
...
@@ -8,7 +8,7 @@ from django.core import validators
from
django.db
import
models
from
django.utils.text
import
capfirst
from
rest_framework.compat
import
DecimalValidator
from
rest_framework.compat
import
DecimalValidator
,
JSONField
from
rest_framework.validators
import
UniqueValidator
NUMERIC_FIELD_TYPES
=
(
...
...
@@ -88,7 +88,7 @@ def get_field_kwargs(field_name, model_field):
if
decimal_places
is
not
None
:
kwargs
[
'decimal_places'
]
=
decimal_places
if
isinstance
(
model_field
,
models
.
TextField
):
if
isinstance
(
model_field
,
models
.
TextField
)
or
(
JSONField
and
isinstance
(
model_field
,
JSONField
))
:
kwargs
[
'style'
]
=
{
'base_template'
:
'textarea.html'
}
if
isinstance
(
model_field
,
models
.
AutoField
)
or
not
model_field
.
editable
:
...
...
rest_framework/utils/serializer_helpers.py
View file @
7a0bd1c4
...
...
@@ -85,7 +85,7 @@ class BoundField(object):
class
JSONBoundField
(
BoundField
):
def
as_form_field
(
self
):
value
=
json
.
dumps
(
self
.
value
)
value
=
json
.
dumps
(
self
.
value
,
sort_keys
=
True
,
indent
=
4
)
return
self
.
__class__
(
self
.
_field
,
value
,
self
.
errors
,
self
.
_prefix
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment