There's one warning to handle here. Signed-off-by: Stephen Finucane <step...@that.guru> --- README.rst | 2 +- patchwork/api/filters.py | 5 +++-- patchwork/compat.py | 17 +++++++++++++++++ .../django-filter-1-1-6a6b0ab8cbe0faca.yaml | 6 ++++++ requirements-dev.txt | 2 +- requirements-prod.txt | 2 +- tox.ini | 3 ++- 7 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/django-filter-1-1-6a6b0ab8cbe0faca.yaml
diff --git a/README.rst b/README.rst index ddc4b981..94ac32c3 100644 --- a/README.rst +++ b/README.rst @@ -47,7 +47,7 @@ Requirements - Django REST Framework (3.4 - 3.8) -- Django Filters (1.0) +- Django Filters (1.0 - 1.1) Development Installation ------------------------ diff --git a/patchwork/api/filters.py b/patchwork/api/filters.py index 73353d90..ddf527fd 100644 --- a/patchwork/api/filters.py +++ b/patchwork/api/filters.py @@ -26,6 +26,7 @@ from django_filters import ModelMultipleChoiceFilter from django.forms import ModelMultipleChoiceField as BaseMultipleChoiceField from django.forms.widgets import MultipleHiddenInput +from patchwork.compat import NAME_FIELD from patchwork.models import Bundle from patchwork.models import Check from patchwork.models import CoverLetter @@ -151,8 +152,8 @@ class UserFilter(ModelMultipleChoiceFilter): class TimestampMixin(FilterSet): # TODO(stephenfin): These should filter on a 'updated_at' field instead - before = IsoDateTimeFilter(name='date', lookup_expr='lt') - since = IsoDateTimeFilter(name='date', lookup_expr='gte') + before = IsoDateTimeFilter(lookup_expr='lt', **{NAME_FIELD: 'date'}) + since = IsoDateTimeFilter(lookup_expr='gte', **{NAME_FIELD: 'date'}) class SeriesFilterSet(TimestampMixin, FilterSet): diff --git a/patchwork/compat.py b/patchwork/compat.py index 38caa4e8..e74e9264 100644 --- a/patchwork/compat.py +++ b/patchwork/compat.py @@ -41,6 +41,23 @@ if settings.ENABLE_REST_API: from rest_framework.filters import DjangoFilterBackend # noqa +# NAME_FIELD +# +# The django-filter library renamed 'Filter.name' to 'Filter.field_name' in +# 1.1. +# +# https://django-filter.readthedocs.io/en/master/guide/migration.html\ +# #migrating-to-2-0 + +if settings.ENABLE_REST_API: + import django_filters # noqa + + if django_filters.VERSION >= (1, 1): + NAME_FIELD = 'field_name' + else: + NAME_FIELD = 'name' + + # reverse, reverse_lazy # # The reverse and reverse_lazy functions have been moved to django.urls in diff --git a/releasenotes/notes/django-filter-1-1-6a6b0ab8cbe0faca.yaml b/releasenotes/notes/django-filter-1-1-6a6b0ab8cbe0faca.yaml new file mode 100644 index 00000000..3beb9c08 --- /dev/null +++ b/releasenotes/notes/django-filter-1-1-6a6b0ab8cbe0faca.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - | + `django-filter 1.1 + <https://github.com/carltongibson/django-filter/releases/tag/1.1.0>`_ is + now supported. diff --git a/requirements-dev.txt b/requirements-dev.txt index b12246dd..1d58df71 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,4 +1,4 @@ Django>=1.8,<2.0 djangorestframework>=3.4,<3.9 -django-filter>=1.0,<1.1 +django-filter>=1.0,<1.2 -r requirements-test.txt diff --git a/requirements-prod.txt b/requirements-prod.txt index 42ff8ecd..59e2c1e6 100644 --- a/requirements-prod.txt +++ b/requirements-prod.txt @@ -1,5 +1,5 @@ Django>=1.8,<2.0 djangorestframework>=3.4,<3.9 -django-filter>=1.0,<1.1 +django-filter>=1.0,<1.2 psycopg2>=2.7,<2.8 sqlparse==0.2.4 diff --git a/tox.ini b/tox.ini index c1bc64e3..9aac8247 100644 --- a/tox.ini +++ b/tox.ini @@ -13,7 +13,8 @@ deps = django{18,19}: djangorestframework>=3.4,<3.7 django110: djangorestframework>=3.4,<3.9 django111: djangorestframework>=3.6,<3.9 - django{18,19,110,111}: django-filter>=1.0,<1.1 + django18: django-filter>=1.0,<1.1 + django{19,110,111}: django-filter>=1.0,<1.2 setenv = DJANGO_SETTINGS_MODULE = patchwork.settings.dev PYTHONDONTWRITEBYTECODE = 1 -- 2.17.1 _______________________________________________ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork