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
a7390fe7
Commit
a7390fe7
authored
Oct 19, 2012
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix up widget choices
parent
dab177e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
rest_framework/renderers.py
+11
-2
No files found.
rest_framework/renderers.py
View file @
a7390fe7
...
...
@@ -6,6 +6,7 @@ on the response, such as JSON encoded data or HTML output.
REST framework also provides an HTML renderer the renders the browseable API.
"""
import
copy
import
string
from
django
import
forms
from
django.http.multipartparser
import
parse_header
...
...
@@ -283,11 +284,19 @@ class BrowsableAPIRenderer(BaseRenderer):
if
getattr
(
v
,
'queryset'
,
None
):
kwargs
[
'queryset'
]
=
v
.
queryset
if
getattr
(
v
,
'widget'
,
None
):
kwargs
[
'widget'
]
=
v
.
widget
widget
=
copy
.
deepcopy
(
v
.
widget
)
# If choices have friendly readable names,
# then add in the identities too
if
getattr
(
widget
,
'choices'
,
None
):
choices
=
widget
.
choices
if
any
([
ident
!=
desc
for
(
ident
,
desc
)
in
choices
]):
choices
=
[(
ident
,
"
%
s (
%
s)"
%
(
desc
,
ident
))
for
(
ident
,
desc
)
in
choices
]
widget
.
choices
=
choices
kwargs
[
'widget'
]
=
widget
if
getattr
(
v
,
'initial'
,
None
):
kwargs
[
'initial'
]
=
v
.
initial
kwargs
[
'label'
]
=
k
print
kwargs
try
:
fields
[
k
]
=
field_mapping
[
v
.
__class__
](
**
kwargs
)
...
...
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