git: 80b4f695a700 - main - www/py-django-tagging: Add Django 3.2 compatibility

From: Kai Knoblich <kai_at_FreeBSD.org>
Date: Thu, 30 Jun 2022 07:20:03 UTC
The branch main has been updated by kai:

URL: https://cgit.FreeBSD.org/ports/commit/?id=80b4f695a700f521a0c0415009a1536cd5987123

commit 80b4f695a700f521a0c0415009a1536cd5987123
Author:     Kevin Golding <ports@caomhin.org>
AuthorDate: 2022-06-30 07:04:53 +0000
Commit:     Kai Knoblich <kai@FreeBSD.org>
CommitDate: 2022-06-30 07:19:28 +0000

    www/py-django-tagging: Add Django 3.2 compatibility
    
    * Add a patch to incorporate an upstream pull-request [1] to address the
      Django 2.2 deprecation [2] and set dependency to Django 3.2.
    
    PR:             263216, 261313 [2]
    Obtained from:  [1] https://github.com/Fantomas42/django-tagging/pull/23/
---
 www/py-django-tagging/Makefile                     |  3 ++-
 .../files/patch-tagging_models.py                  | 22 ++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/www/py-django-tagging/Makefile b/www/py-django-tagging/Makefile
index db38462200b1..fe2b06a7c88a 100644
--- a/www/py-django-tagging/Makefile
+++ b/www/py-django-tagging/Makefile
@@ -2,6 +2,7 @@
 
 PORTNAME=	django-tagging
 PORTVERSION=	0.5.0
+PORTREVISION=	1
 CATEGORIES=	www python
 MASTER_SITES=	CHEESESHOP
 PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
@@ -13,7 +14,7 @@ LICENSE=	BSD3CLAUSE MIT
 LICENSE_COMB=	multi
 LICENSE_FILE=	${WRKSRC}/LICENSE.txt
 
-RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}django22>=1.11:www/py-django22@${PY_FLAVOR}
+RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}django32>=0:www/py-django32@${PY_FLAVOR}
 
 USES=		python:3.5+
 USE_PYTHON=	distutils autoplist
diff --git a/www/py-django-tagging/files/patch-tagging_models.py b/www/py-django-tagging/files/patch-tagging_models.py
new file mode 100644
index 000000000000..5c4c00ac7116
--- /dev/null
+++ b/www/py-django-tagging/files/patch-tagging_models.py
@@ -0,0 +1,22 @@
+--- tagging/models.py.orig	2022-04-11 10:40:39 UTC
++++ tagging/models.py
+@@ -5,6 +5,7 @@ from django.contrib.contenttypes.fields import Generic
+ from django.contrib.contenttypes.models import ContentType
+ from django.db import connection
+ from django.db import models
++from django.db.models.query_utils import Q
+ from django.utils.encoding import smart_text
+ from django.utils.translation import gettext_lazy as _
+ 
+@@ -155,8 +156,9 @@ class TagManager(models.Manager):
+             filters = {}
+ 
+         queryset = model._default_manager.filter()
+-        for f in filters.items():
+-            queryset.query.add_filter(f)
++        for k, v in filters.items():
++            # Add support for both Django 4 and inferior versions
++            queryset.query.add_q(Q((k, v)))
+         usage = self.usage_for_queryset(queryset, counts, min_count)
+ 
+         return usage