Skip to content

Commit be6b2bf

Browse files
committed
Adding comments to filter_for_reverse_field()
1 parent 64ec0ca commit be6b2bf

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

graphene/contrib/django/filter/filterset.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,22 @@ class GrapheneFilterSetMixin(object):
5858

5959
@classmethod
6060
def filter_for_reverse_field(cls, f, name):
61+
"""Handles retrieving filters for reverse relationships
62+
63+
We override the default implementation so that we can handle
64+
Global IDs (the default implementation expects database
65+
primary keys)
66+
"""
6167
rel = f.field.rel
6268
default = {
6369
'name': name,
6470
'label': capfirst(rel.related_name)
6571
}
6672
if rel.multiple:
73+
# For to-many relationships
6774
return GlobalIDMultipleChoiceFilter(**default)
6875
else:
76+
# For to-one relationships
6977
return GlobalIDFilter(**default)
7078

7179

0 commit comments

Comments
 (0)