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
21bac854
Commit
21bac854
authored
Apr 22, 2015
by
kazmiruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move compatibility checks into compat.py
parent
1116a534
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
33 deletions
+15
-33
rest_framework/compat.py
+10
-0
rest_framework/fields.py
+1
-6
rest_framework/routers.py
+1
-5
rest_framework/serializers.py
+1
-10
rest_framework/utils/encoders.py
+1
-6
rest_framework/views.py
+1
-6
No files found.
rest_framework/compat.py
View file @
21bac854
...
@@ -265,3 +265,13 @@ except ImportError:
...
@@ -265,3 +265,13 @@ except ImportError:
klass
.
__unicode__
=
klass
.
__str__
klass
.
__unicode__
=
klass
.
__str__
klass
.
__str__
=
lambda
self
:
self
.
__unicode__
()
.
encode
(
'utf-8'
)
klass
.
__str__
=
lambda
self
:
self
.
__unicode__
()
.
encode
(
'utf-8'
)
return
klass
return
klass
try
:
from
collections
import
OrderedDict
except
ImportError
:
from
django.utils.datastructures
import
SortedDict
as
OrderedDict
if
django
.
VERSION
>=
(
1
,
8
):
from
django.contrib.contenttypes.fields
import
GenericForeignKey
else
:
from
django.contrib.contenttypes.generic
import
GenericForeignKey
rest_framework/fields.py
View file @
21bac854
...
@@ -25,16 +25,11 @@ from django.utils.translation import ugettext_lazy as _
...
@@ -25,16 +25,11 @@ from django.utils.translation import ugettext_lazy as _
from
django.utils.dateparse
import
parse_date
,
parse_datetime
,
parse_time
from
django.utils.dateparse
import
parse_date
,
parse_datetime
,
parse_time
from
rest_framework
import
ISO_8601
from
rest_framework
import
ISO_8601
from
rest_framework.compat
import
(
from
rest_framework.compat
import
(
BytesIO
,
smart_text
,
BytesIO
,
smart_text
,
OrderedDict
,
force_text
,
is_non_str_iterable
force_text
,
is_non_str_iterable
)
)
from
rest_framework.settings
import
api_settings
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
):
def
is_simple_callable
(
obj
):
"""
"""
...
...
rest_framework/routers.py
View file @
21bac854
...
@@ -21,15 +21,11 @@ from django.conf.urls import patterns, url
...
@@ -21,15 +21,11 @@ from django.conf.urls import patterns, url
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.exceptions
import
ImproperlyConfigured
from
django.core.urlresolvers
import
NoReverseMatch
from
django.core.urlresolvers
import
NoReverseMatch
from
rest_framework
import
views
from
rest_framework
import
views
from
rest_framework.compat
import
OrderedDict
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework.reverse
import
reverse
from
rest_framework.reverse
import
reverse
from
rest_framework.urlpatterns
import
format_suffix_patterns
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'
])
Route
=
namedtuple
(
'Route'
,
[
'url'
,
'mapping'
,
'name'
,
'initkwargs'
])
DynamicDetailRoute
=
namedtuple
(
'DynamicDetailRoute'
,
[
'url'
,
'name'
,
'initkwargs'
])
DynamicDetailRoute
=
namedtuple
(
'DynamicDetailRoute'
,
[
'url'
,
'name'
,
'initkwargs'
])
...
...
rest_framework/serializers.py
View file @
21bac854
...
@@ -23,6 +23,7 @@ from django.forms import widgets
...
@@ -23,6 +23,7 @@ from django.forms import widgets
from
django.utils
import
six
from
django.utils
import
six
from
django.utils.functional
import
cached_property
from
django.utils.functional
import
cached_property
from
django.core.exceptions
import
ObjectDoesNotExist
from
django.core.exceptions
import
ObjectDoesNotExist
from
rest_framework.compat
import
OrderedDict
,
GenericForeignKey
from
rest_framework.settings
import
api_settings
from
rest_framework.settings
import
api_settings
...
@@ -36,16 +37,6 @@ from rest_framework.settings import api_settings
...
@@ -36,16 +37,6 @@ from rest_framework.settings import api_settings
from
rest_framework.relations
import
*
# NOQA
from
rest_framework.relations
import
*
# NOQA
from
rest_framework.fields
import
*
# NOQA
from
rest_framework.fields
import
*
# NOQA
try
:
from
collections
import
OrderedDict
except
ImportError
:
from
django.utils.datastructures
import
SortedDict
as
OrderedDict
if
django
.
VERSION
>=
(
1
,
8
):
from
django.contrib.contenttypes.fields
import
GenericForeignKey
else
:
from
django.contrib.contenttypes.generic
import
GenericForeignKey
def
_resolve_model
(
obj
):
def
_resolve_model
(
obj
):
"""
"""
...
...
rest_framework/utils/encoders.py
View file @
21bac854
...
@@ -5,18 +5,13 @@ from __future__ import unicode_literals
...
@@ -5,18 +5,13 @@ from __future__ import unicode_literals
from
django.utils
import
timezone
from
django.utils
import
timezone
from
django.db.models.query
import
QuerySet
from
django.db.models.query
import
QuerySet
from
django.utils.functional
import
Promise
from
django.utils.functional
import
Promise
from
rest_framework.compat
import
force_text
from
rest_framework.compat
import
force_text
,
OrderedDict
from
rest_framework.serializers
import
DictWithMetadata
,
OrderedDictWithMetadata
from
rest_framework.serializers
import
DictWithMetadata
,
OrderedDictWithMetadata
import
datetime
import
datetime
import
decimal
import
decimal
import
types
import
types
import
json
import
json
try
:
from
collections
import
OrderedDict
except
ImportError
:
from
django.utils.datastructures
import
SortedDict
as
OrderedDict
class
JSONEncoder
(
json
.
JSONEncoder
):
class
JSONEncoder
(
json
.
JSONEncoder
):
"""
"""
...
...
rest_framework/views.py
View file @
21bac854
...
@@ -7,17 +7,12 @@ from django.core.exceptions import PermissionDenied
...
@@ -7,17 +7,12 @@ from django.core.exceptions import PermissionDenied
from
django.http
import
Http404
from
django.http
import
Http404
from
django.views.decorators.csrf
import
csrf_exempt
from
django.views.decorators.csrf
import
csrf_exempt
from
rest_framework
import
status
,
exceptions
from
rest_framework
import
status
,
exceptions
from
rest_framework.compat
import
smart_text
,
HttpResponseBase
,
View
from
rest_framework.compat
import
smart_text
,
HttpResponseBase
,
OrderedDict
,
View
from
rest_framework.request
import
Request
from
rest_framework.request
import
Request
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
rest_framework.settings
import
api_settings
from
rest_framework.settings
import
api_settings
from
rest_framework.utils
import
formatting
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
):
def
get_view_name
(
view_cls
,
suffix
=
None
):
"""
"""
...
...
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