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
8d51759d
Commit
8d51759d
authored
Jul 01, 2011
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bitbucket issue 39. All further issues should be on github
parent
2ebcc9d3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
5 deletions
+6
-5
AUTHORS
+1
-0
README
+1
-1
djangorestframework/serializer.py
+4
-4
No files found.
AUTHORS
View file @
8d51759d
...
...
@@ -9,6 +9,7 @@ Carles Barrobés <txels> - HEAD support.
Michael Fötsch <mfoetsch> - File format support.
David Larlet <david> - OAuth support.
Andrew Straw <astraw> - Bugfixes.
<zeth> - Bugfixes.
THANKS TO:
...
...
README
View file @
8d51759d
...
...
@@ -6,7 +6,7 @@ To install django-rest-framework in a virtualenv environment
hg clone https://tomchristie@bitbucket.org/tomchristie/django-rest-framework
cd django-rest-framework/
virtualenv --no-site-packages --distribute --python=python2.6 env
source
./
env/bin/activate
source env/bin/activate
pip install -r requirements.txt # django, coverage
...
...
djangorestframework/serializer.py
View file @
8d51759d
...
...
@@ -4,7 +4,7 @@ Customizable serialization.
from
django.db
import
models
from
django.db.models.query
import
QuerySet
from
django.db.models.fields.related
import
RelatedField
from
django.utils.encoding
import
smart_unicode
,
is_protected_type
from
django.utils.encoding
import
smart_unicode
,
is_protected_type
,
smart_str
import
decimal
import
inspect
...
...
@@ -177,7 +177,7 @@ class Serializer(object):
Keys serialize to their string value,
unless they exist in the `rename` dict.
"""
return
getattr
(
self
.
rename
,
key
,
key
)
return
getattr
(
self
.
rename
,
smart_str
(
key
),
smart_str
(
key
)
)
def
serialize_val
(
self
,
key
,
obj
):
...
...
@@ -228,12 +228,12 @@ class Serializer(object):
# serialize each required field
for
fname
in
fields
:
if
hasattr
(
self
,
fname
):
if
hasattr
(
self
,
smart_str
(
fname
)
):
# check for a method 'fname' on self first
meth
=
getattr
(
self
,
fname
)
if
inspect
.
ismethod
(
meth
)
and
len
(
inspect
.
getargspec
(
meth
)[
0
])
==
2
:
obj
=
meth
(
instance
)
elif
hasattr
(
instance
,
fname
):
elif
hasattr
(
instance
,
smart_str
(
fname
)
):
# now check for an attribute 'fname' on the instance
obj
=
getattr
(
instance
,
fname
)
elif
fname
in
instance
:
...
...
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