Skip to content

Commit ddacb9d

Browse files
committed
Drop support for django-filter < 2
It was only needed for Python 2.7
1 parent 1577571 commit ddacb9d

File tree

2 files changed

+3
-34
lines changed

2 files changed

+3
-34
lines changed

docs/filtering.rst

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ Filtering
22
=========
33

44
Graphene integrates with
5-
`django-filter <https://django-filter.readthedocs.io/en/master/>`__ (2.x for
6-
Python 3 or 1.x for Python 2) to provide filtering of results. See the `usage
7-
documentation <https://django-filter.readthedocs.io/en/master/guide/usage.html#the-filter>`__
5+
`django-filter <https://django-filter.readthedocs.io/en/master/>`__ to provide filtering of results.
6+
See the `usage documentation <https://django-filter.readthedocs.io/en/master/guide/usage.html#the-filter>`__
87
for details on the format for ``filter_fields``.
98

109
This filtering is automatically available when implementing a ``relay.Node``.

graphene_django/filter/filterset.py

+1-31
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import itertools
22

33
from django.db import models
4-
from django_filters import Filter, MultipleChoiceFilter, VERSION
4+
from django_filters import Filter, MultipleChoiceFilter
55
from django_filters.filterset import BaseFilterSet, FilterSet
66
from django_filters.filterset import FILTER_FOR_DBFIELD_DEFAULTS
77

@@ -50,36 +50,6 @@ class GrapheneFilterSetMixin(BaseFilterSet):
5050
)
5151

5252

53-
# To support a Django 1.11 + Python 2.7 combination django-filter must be
54-
# < 2.x.x. To support the earlier version of django-filter, the
55-
# filter_for_reverse_field method must be present on GrapheneFilterSetMixin and
56-
# must not be present for later versions of django-filter.
57-
if VERSION[0] < 2:
58-
from django.utils.text import capfirst
59-
60-
class GrapheneFilterSetMixinPython2(GrapheneFilterSetMixin):
61-
@classmethod
62-
def filter_for_reverse_field(cls, f, name):
63-
"""Handles retrieving filters for reverse relationships
64-
We override the default implementation so that we can handle
65-
Global IDs (the default implementation expects database
66-
primary keys)
67-
"""
68-
try:
69-
rel = f.field.remote_field
70-
except AttributeError:
71-
rel = f.field.rel
72-
default = {"name": name, "label": capfirst(rel.related_name)}
73-
if rel.multiple:
74-
# For to-many relationships
75-
return GlobalIDMultipleChoiceFilter(**default)
76-
else:
77-
# For to-one relationships
78-
return GlobalIDFilter(**default)
79-
80-
GrapheneFilterSetMixin = GrapheneFilterSetMixinPython2
81-
82-
8353
def setup_filterset(filterset_class):
8454
""" Wrap a provided filterset in Graphene-specific functionality
8555
"""

0 commit comments

Comments
 (0)