|
1 | 1 | import itertools |
2 | 2 |
|
3 | 3 | from django.db import models |
4 | | -from django_filters import Filter, MultipleChoiceFilter, VERSION |
| 4 | +from django_filters import Filter, MultipleChoiceFilter |
5 | 5 | from django_filters.filterset import BaseFilterSet, FilterSet |
6 | 6 | from django_filters.filterset import FILTER_FOR_DBFIELD_DEFAULTS |
7 | 7 |
|
@@ -50,36 +50,6 @@ class GrapheneFilterSetMixin(BaseFilterSet): |
50 | 50 | ) |
51 | 51 |
|
52 | 52 |
|
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 | | - |
83 | 53 | def setup_filterset(filterset_class): |
84 | 54 | """ Wrap a provided filterset in Graphene-specific functionality |
85 | 55 | """ |
|
0 commit comments