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
25a703b4
Commit
25a703b4
authored
Jan 23, 2015
by
Tom Christie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work around meta API differences
parent
e56f0a92
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
2 deletions
+8
-2
rest_framework/utils/model_meta.py
+8
-2
No files found.
rest_framework/utils/model_meta.py
View file @
25a703b4
...
...
@@ -121,12 +121,17 @@ def _get_reverse_relationships(opts):
"""
Returns an `OrderedDict` of field names to `RelationInfo`.
"""
# Note that we have a hack here to handle internal API differences for
# this internal API across Django 1.7 -> Django 1.8.
# See: https://code.djangoproject.com/ticket/24208
reverse_relations
=
OrderedDict
()
for
relation
in
opts
.
get_all_related_objects
():
accessor_name
=
relation
.
get_accessor_name
()
related
=
getattr
(
relation
,
'related_model'
,
relation
.
model
)
reverse_relations
[
accessor_name
]
=
RelationInfo
(
model_field
=
None
,
related
=
relat
ion
.
model
,
related
=
relat
ed
,
to_many
=
relation
.
field
.
rel
.
multiple
,
has_through_model
=
False
)
...
...
@@ -134,9 +139,10 @@ def _get_reverse_relationships(opts):
# Deal with reverse many-to-many relationships.
for
relation
in
opts
.
get_all_related_many_to_many_objects
():
accessor_name
=
relation
.
get_accessor_name
()
related
=
getattr
(
relation
,
'related_model'
,
relation
.
model
)
reverse_relations
[
accessor_name
]
=
RelationInfo
(
model_field
=
None
,
related
=
relat
ion
.
model
,
related
=
relat
ed
,
to_many
=
True
,
has_through_model
=
(
(
getattr
(
relation
.
field
.
rel
,
'through'
,
None
)
is
not
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