From d55f42658f6a9fb07cd123e34dbb6b867e3db00d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=9Clgen=20Sar=C4=B1kavak?= Date: Sat, 14 Mar 2020 13:35:39 +0300 Subject: [PATCH] Drop support for django-filter < 2 --- docs/filtering.rst | 3 +-- graphene_django/filter/filterset.py | 30 ----------------------------- 2 files changed, 1 insertion(+), 32 deletions(-) diff --git a/docs/filtering.rst b/docs/filtering.rst index 6fe7cab..fb73744 100644 --- a/docs/filtering.rst +++ b/docs/filtering.rst @@ -2,8 +2,7 @@ Filtering ========= Graphene integrates with -`django-filter `__ (2.x for -Python 3 or 1.x for Python 2) to provide filtering of results. See the `usage +`django-filter `__ to provide filtering of results. See the `usage documentation `__ for details on the format for ``filter_fields``. diff --git a/graphene_django/filter/filterset.py b/graphene_django/filter/filterset.py index 7676ea8..cf3b873 100644 --- a/graphene_django/filter/filterset.py +++ b/graphene_django/filter/filterset.py @@ -50,36 +50,6 @@ class GrapheneFilterSetMixin(BaseFilterSet): ) -# To support a Django 1.11 + Python 2.7 combination django-filter must be -# < 2.x.x. To support the earlier version of django-filter, the -# filter_for_reverse_field method must be present on GrapheneFilterSetMixin and -# must not be present for later versions of django-filter. -if VERSION[0] < 2: - from django.utils.text import capfirst - - class GrapheneFilterSetMixinPython2(GrapheneFilterSetMixin): - @classmethod - def filter_for_reverse_field(cls, f, name): - """Handles retrieving filters for reverse relationships - We override the default implementation so that we can handle - Global IDs (the default implementation expects database - primary keys) - """ - try: - rel = f.field.remote_field - except AttributeError: - rel = f.field.rel - default = {"name": name, "label": capfirst(rel.related_name)} - if rel.multiple: - # For to-many relationships - return GlobalIDMultipleChoiceFilter(**default) - else: - # For to-one relationships - return GlobalIDFilter(**default) - - GrapheneFilterSetMixin = GrapheneFilterSetMixinPython2 - - def setup_filterset(filterset_class): """ Wrap a provided filterset in Graphene-specific functionality """