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
389b48e3
Commit
389b48e3
authored
Nov 18, 2015
by
Ryan Hiebert
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid making a new module for this function
parent
dca2de3a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
rest_framework/relations.py
+11
-2
rest_framework/utils/overridden.py
+0
-7
No files found.
rest_framework/relations.py
View file @
389b48e3
...
...
@@ -18,7 +18,16 @@ from rest_framework.fields import (
Field
,
empty
,
get_attribute
,
is_simple_callable
,
iter_options
)
from
rest_framework.reverse
import
reverse
from
rest_framework.utils
import
html
,
overridden
from
rest_framework.utils
import
html
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__
class
Hyperlink
(
six
.
text_type
):
...
...
@@ -63,7 +72,7 @@ class RelatedField(Field):
self
.
html_cutoff
=
kwargs
.
pop
(
'html_cutoff'
,
self
.
html_cutoff
)
self
.
html_cutoff_text
=
kwargs
.
pop
(
'html_cutoff_text'
,
self
.
html_cutoff_text
)
if
not
overridden
.
method_overridden
(
'get_queryset'
,
RelatedField
,
self
):
if
not
method_overridden
(
'get_queryset'
,
RelatedField
,
self
):
assert
self
.
queryset
is
not
None
or
kwargs
.
get
(
'read_only'
,
None
),
(
'Relational field must provide a `queryset` argument, '
'or set read_only=`True`.'
...
...
rest_framework/utils/overridden.py
deleted
100644 → 0
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