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
dca2de3a
Commit
dca2de3a
authored
Nov 16, 2015
by
Ryan Hiebert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the override check a utility function
parent
fe12816b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
rest_framework/relations.py
+2
-4
rest_framework/utils/overridden.py
+7
-0
No files found.
rest_framework/relations.py
View file @
dca2de3a
...
@@ -18,7 +18,7 @@ from rest_framework.fields import (
...
@@ -18,7 +18,7 @@ from rest_framework.fields import (
Field
,
empty
,
get_attribute
,
is_simple_callable
,
iter_options
Field
,
empty
,
get_attribute
,
is_simple_callable
,
iter_options
)
)
from
rest_framework.reverse
import
reverse
from
rest_framework.reverse
import
reverse
from
rest_framework.utils
import
html
from
rest_framework.utils
import
html
,
overridden
class
Hyperlink
(
six
.
text_type
):
class
Hyperlink
(
six
.
text_type
):
...
@@ -63,9 +63,7 @@ class RelatedField(Field):
...
@@ -63,9 +63,7 @@ class RelatedField(Field):
self
.
html_cutoff
=
kwargs
.
pop
(
'html_cutoff'
,
self
.
html_cutoff
)
self
.
html_cutoff
=
kwargs
.
pop
(
'html_cutoff'
,
self
.
html_cutoff
)
self
.
html_cutoff_text
=
kwargs
.
pop
(
'html_cutoff_text'
,
self
.
html_cutoff_text
)
self
.
html_cutoff_text
=
kwargs
.
pop
(
'html_cutoff_text'
,
self
.
html_cutoff_text
)
default_get_queryset
=
getattr
(
RelatedField
.
get_queryset
,
'__func__'
,
if
not
overridden
.
method_overridden
(
'get_queryset'
,
RelatedField
,
self
):
RelatedField
.
get_queryset
)
# Python 2/3
if
self
.
get_queryset
.
__func__
==
default_get_queryset
:
assert
self
.
queryset
is
not
None
or
kwargs
.
get
(
'read_only'
,
None
),
(
assert
self
.
queryset
is
not
None
or
kwargs
.
get
(
'read_only'
,
None
),
(
'Relational field must provide a `queryset` argument, '
'Relational field must provide a `queryset` argument, '
'or set read_only=`True`.'
'or set read_only=`True`.'
...
...
rest_framework/utils/overridden.py
0 → 100644
View file @
dca2de3a
def
method_overridden
(
method_name
,
klass
,
instance
):
"""
Determine if a method has been overridden.
"""
method
=
getattr
(
klass
,
method_name
)
default_method
=
getattr
(
method
,
'__func__'
,
method
)
# Python 3 compat
return
default_method
is
not
getattr
(
instance
,
method_name
)
.
__func__
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