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
47c61679
Commit
47c61679
authored
Apr 22, 2015
by
kazmiruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adds backward compatibility
parent
e4e3f573
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
7 deletions
+33
-7
rest_framework/fields.py
+7
-2
rest_framework/routers.py
+6
-1
rest_framework/serializers.py
+5
-1
rest_framework/utils/encoders.py
+5
-1
rest_framework/views.py
+5
-1
tests/test_fields.py
+5
-1
No files found.
rest_framework/fields.py
View file @
47c61679
...
...
@@ -30,6 +30,11 @@ from rest_framework.compat import (
)
from
rest_framework.settings
import
api_settings
try
:
from
collections
import
OrderedDict
except
ImportError
:
from
django.utils.datastructures
import
SortedDict
as
OrderedDict
def
is_simple_callable
(
obj
):
"""
...
...
@@ -224,7 +229,7 @@ class Field(object):
return
[
self
.
to_native
(
item
)
for
item
in
value
]
elif
isinstance
(
value
,
dict
):
# Make sure we preserve field ordering, if it exists
ret
=
collections
.
OrderedDict
()
ret
=
OrderedDict
()
for
key
,
val
in
value
.
items
():
ret
[
key
]
=
self
.
to_native
(
val
)
return
ret
...
...
@@ -239,7 +244,7 @@ class Field(object):
return
{}
def
metadata
(
self
):
metadata
=
collections
.
OrderedDict
()
metadata
=
OrderedDict
()
metadata
[
'type'
]
=
self
.
type_label
metadata
[
'required'
]
=
getattr
(
self
,
'required'
,
False
)
optional_attrs
=
[
'read_only'
,
'label'
,
'help_text'
,
...
...
rest_framework/routers.py
View file @
47c61679
...
...
@@ -16,7 +16,7 @@ For example, you might have a `urls.py` that looks something like this:
from
__future__
import
unicode_literals
import
itertools
from
collections
import
namedtuple
,
OrderedDict
from
collections
import
namedtuple
from
django.conf.urls
import
patterns
,
url
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.urlresolvers
import
NoReverseMatch
...
...
@@ -25,6 +25,11 @@ from rest_framework.response import Response
from
rest_framework.reverse
import
reverse
from
rest_framework.urlpatterns
import
format_suffix_patterns
try
:
from
collections
import
OrderedDict
except
ImportError
:
from
django.utils.datastructures
import
SortedDict
as
OrderedDict
Route
=
namedtuple
(
'Route'
,
[
'url'
,
'mapping'
,
'name'
,
'initkwargs'
])
DynamicDetailRoute
=
namedtuple
(
'DynamicDetailRoute'
,
[
'url'
,
'name'
,
'initkwargs'
])
...
...
rest_framework/serializers.py
View file @
47c61679
...
...
@@ -11,7 +11,6 @@ python primitives.
response content is handled by parsers and renderers.
"""
from
__future__
import
unicode_literals
from
collections
import
OrderedDict
import
copy
import
datetime
import
inspect
...
...
@@ -37,6 +36,11 @@ from rest_framework.settings import api_settings
from
rest_framework.relations
import
*
# NOQA
from
rest_framework.fields
import
*
# NOQA
try
:
from
collections
import
OrderedDict
except
ImportError
:
from
django.utils.datastructures
import
SortedDict
as
OrderedDict
def
_resolve_model
(
obj
):
"""
...
...
rest_framework/utils/encoders.py
View file @
47c61679
...
...
@@ -2,7 +2,6 @@
Helper classes for parsers.
"""
from
__future__
import
unicode_literals
from
collections
import
OrderedDict
from
django.utils
import
timezone
from
django.db.models.query
import
QuerySet
from
django.utils.functional
import
Promise
...
...
@@ -13,6 +12,11 @@ import decimal
import
types
import
json
try
:
from
collections
import
OrderedDict
except
ImportError
:
from
django.utils.datastructures
import
SortedDict
as
OrderedDict
class
JSONEncoder
(
json
.
JSONEncoder
):
"""
...
...
rest_framework/views.py
View file @
47c61679
...
...
@@ -3,7 +3,6 @@ Provides an APIView class that is the base of all views in REST framework.
"""
from
__future__
import
unicode_literals
from
collections
import
OrderedDict
from
django.core.exceptions
import
PermissionDenied
from
django.http
import
Http404
from
django.views.decorators.csrf
import
csrf_exempt
...
...
@@ -14,6 +13,11 @@ from rest_framework.response import Response
from
rest_framework.settings
import
api_settings
from
rest_framework.utils
import
formatting
try
:
from
collections
import
OrderedDict
except
ImportError
:
from
django.utils.datastructures
import
SortedDict
as
OrderedDict
def
get_view_name
(
view_cls
,
suffix
=
None
):
"""
...
...
tests/test_fields.py
View file @
47c61679
...
...
@@ -3,7 +3,6 @@ General serializer field tests.
"""
from
__future__
import
unicode_literals
from
collections
import
OrderedDict
import
datetime
import
re
from
decimal
import
Decimal
...
...
@@ -14,6 +13,11 @@ from django.test import TestCase
from
rest_framework
import
serializers
from
tests.models
import
RESTFrameworkModel
try
:
from
collections
import
OrderedDict
except
ImportError
:
from
django.utils.datastructures
import
SortedDict
as
OrderedDict
class
TimestampedModel
(
models
.
Model
):
added
=
models
.
DateTimeField
(
auto_now_add
=
True
)
...
...
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