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
81d0b748
Commit
81d0b748
authored
Dec 10, 2014
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve field lookup behavior for dicts/mappings. Closes #2244. Closes #2243.
parent
76956bea
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
6 deletions
+5
-6
rest_framework/fields.py
+5
-6
No files found.
rest_framework/fields.py
View file @
81d0b748
...
@@ -15,6 +15,7 @@ from rest_framework.compat import (
...
@@ -15,6 +15,7 @@ from rest_framework.compat import (
from
rest_framework.exceptions
import
ValidationError
from
rest_framework.exceptions
import
ValidationError
from
rest_framework.settings
import
api_settings
from
rest_framework.settings
import
api_settings
from
rest_framework.utils
import
html
,
representation
,
humanize_datetime
from
rest_framework.utils
import
html
,
representation
,
humanize_datetime
import
collections
import
copy
import
copy
import
datetime
import
datetime
import
decimal
import
decimal
...
@@ -60,14 +61,12 @@ def get_attribute(instance, attrs):
...
@@ -60,14 +61,12 @@ def get_attribute(instance, attrs):
# Break out early if we get `None` at any point in a nested lookup.
# Break out early if we get `None` at any point in a nested lookup.
return
None
return
None
try
:
try
:
instance
=
getattr
(
instance
,
attr
)
if
isinstance
(
instance
,
collections
.
Mapping
):
instance
=
instance
[
attr
]
else
:
instance
=
getattr
(
instance
,
attr
)
except
ObjectDoesNotExist
:
except
ObjectDoesNotExist
:
return
None
return
None
except
AttributeError
as
exc
:
try
:
return
instance
[
attr
]
except
(
KeyError
,
TypeError
,
AttributeError
):
raise
exc
if
is_simple_callable
(
instance
):
if
is_simple_callable
(
instance
):
instance
=
instance
()
instance
=
instance
()
return
instance
return
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