From patchwork Tue Apr 30 06:03:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Axtens X-Patchwork-Id: 1093003 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44tWJ71bHzz9s7T for ; Tue, 30 Apr 2019 16:06:47 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=axtens.net Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=axtens.net header.i=@axtens.net header.b="TdBZm3gG"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 44tWJ70RKszDqMp for ; Tue, 30 Apr 2019 16:06:47 +1000 (AEST) X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=axtens.net (client-ip=2607:f8b0:4864:20::434; helo=mail-pf1-x434.google.com; envelope-from=dja@axtens.net; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=axtens.net Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=axtens.net header.i=@axtens.net header.b="TdBZm3gG"; dkim-atps=neutral Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44tWDs0qkgzDqQX for ; Tue, 30 Apr 2019 16:03:56 +1000 (AEST) Received: by mail-pf1-x434.google.com with SMTP id z26so2654281pfg.6 for ; Mon, 29 Apr 2019 23:03:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1PJJsmvRFtP/HM+IbBFqr+kBN7GACnvnkkW24NMRddA=; b=TdBZm3gGYFmSj7DtOhd87cKxZ/qIhs8Wc1A+STLTR4BVYLmMwX22HSxIYqMMYt2uMl 3n/v/bkQSqIlKG9/gcbvRMOMoI64N0i3VhF8+d4e88qEAX72wRgFYLxsdVbZWXzWSQAG pyocP6VuPWzEN1Rpv8h/j786tN/Pj/X70uPTI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1PJJsmvRFtP/HM+IbBFqr+kBN7GACnvnkkW24NMRddA=; b=HpIqigfcKYzZ5R/E4bpy6k5IF1/MN6keh7qU8p5lBVlfm8LQ2DFQPTubkeZm5mLj2r 4G7PpqaEyIN9iTKC3jRRZJKQ3FGTfBlJ0ltpOdMtZGSKLZXxenD5MawCgMeqHpygk4ND sa1gbbHpifYLqzDTFr90rmbIcqyzSO5KzQ8TxYCMDKpvdkjQyiiXqyeAbnn8952aIjhr 0U0tjPU7lhQajeSQTGDW9d/LKHfLr5k0e8ClhJ3c6zBc+lf3z1MTMAoyT4U9nTeHQ4TW bduZapuFoMvkZwHdmQGLCfEYUzXM+Ekv0Sen3fPeca1sPUfoH9iQUUO7hs+0qBe1XeI2 iyeQ== X-Gm-Message-State: APjAAAVItyO/kCxIc1l1w35QkmnJyKTlXMJ5YKiCRqybM4WG2odtdC4a 1w31JL3TMgLs44dKuh/6P3rpGGlBHuY= X-Google-Smtp-Source: APXvYqzYTSny2OeIMH7FakTAkJsAl6K5KRFCr7FT1wTjl/r7Gj1nO8BxGEKVNKvd/NxxqKtGkDrJOA== X-Received: by 2002:a62:2687:: with SMTP id m129mr23733079pfm.204.1556604233799; Mon, 29 Apr 2019 23:03:53 -0700 (PDT) Received: from localhost (203-217-53-131.dyn.iinet.net.au. [203.217.53.131]) by smtp.gmail.com with ESMTPSA id z12sm2229041pgc.88.2019.04.29.23.03.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 29 Apr 2019 23:03:53 -0700 (PDT) From: Daniel Axtens To: patchwork@lists.ozlabs.org Subject: [PATCH 08/10] Add support for django-filter 1.1 Date: Tue, 30 Apr 2019 16:03:06 +1000 Message-Id: <20190430060308.10432-9-dja@axtens.net> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190430060308.10432-1-dja@axtens.net> References: <20190430060308.10432-1-dja@axtens.net> MIME-Version: 1.0 X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" From: Stephen Finucane There's one warning to handle here. Signed-off-by: Stephen Finucane Signed-off-by: Daniel Axtens (cherry picked from commit 4ad2558f884bf33201e179a171ad3821a62126a1) Signed-off-by: Daniel Axtens --- README.rst | 2 +- patchwork/api/filters.py | 5 +++-- patchwork/compat.py | 16 ++++++++++++++++ .../django-filter-1-1-6a6b0ab8cbe0faca.yaml | 6 ++++++ requirements-dev.txt | 2 +- requirements-prod.txt | 2 +- tox.ini | 3 ++- 7 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/django-filter-1-1-6a6b0ab8cbe0faca.yaml diff --git a/README.rst b/README.rst index ddc4b98125d1..94ac32c3b8b7 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 73353d900a94..ddf527fd837b 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 38caa4e861cf..3bbff447dbcb 100644 --- a/patchwork/compat.py +++ b/patchwork/compat.py @@ -41,6 +41,22 @@ 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 000000000000..3beb9c0848ef --- /dev/null +++ b/releasenotes/notes/django-filter-1-1-6a6b0ab8cbe0faca.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - | + `django-filter 1.1 + `_ is + now supported. diff --git a/requirements-dev.txt b/requirements-dev.txt index b12246dd1b89..1d58df714290 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 42ff8ecd82f1..59e2c1e6ce53 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 5c741d374a64..c242c97f4d8b 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