Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:smarty12:Python
python-django-tagging
django4.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File django4.patch of Package python-django-tagging
From f3622e62112c3ecc89eabb2512b1b3dd2e5e6ca0 Mon Sep 17 00:00:00 2001 From: Fantomas42 <fantomas42@gmail.com> Date: Fri, 6 Mar 2020 19:00:00 +0100 Subject: [PATCH 1/4] Fix typo --- tagging/models.py | 10 ++++++---- tagging/tests/urls.py | 12 ++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) --- a/tagging/models.py +++ b/tagging/models.py @@ -5,7 +5,8 @@ from django.contrib.contenttypes.fields from django.contrib.contenttypes.models import ContentType from django.db import connection from django.db import models -from django.utils.encoding import smart_text +from django.db.models.query_utils import Q +from django.utils.encoding import smart_str from django.utils.translation import gettext_lazy as _ from tagging import settings @@ -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 @@ -519,4 +521,4 @@ class TaggedItem(models.Model): verbose_name_plural = _('tagged items') def __str__(self): - return '%s [%s]' % (smart_text(self.object), smart_text(self.tag)) + return '%s [%s]' % (smart_str(self.object), smart_str(self.tag)) --- a/tagging/tests/urls.py +++ b/tagging/tests/urls.py @@ -1,5 +1,5 @@ """Test urls for tagging.""" -from django.conf.urls import url +from django.urls import re_path from tagging.tests.models import Article from tagging.views import TaggedObjectList @@ -11,10 +11,10 @@ class StaticTaggedObjectList(TaggedObjec urlpatterns = [ - url(r'^static/$', StaticTaggedObjectList.as_view()), - url(r'^static/related/$', StaticTaggedObjectList.as_view( + re_path(r'^static/$', StaticTaggedObjectList.as_view()), + re_path(r'^static/related/$', StaticTaggedObjectList.as_view( related_tags=True)), - url(r'^no-tag/$', TaggedObjectList.as_view(model=Article)), - url(r'^no-query-no-model/$', TaggedObjectList.as_view()), - url(r'^(?P<tag>[^/]+(?u))/$', TaggedObjectList.as_view(model=Article)), + re_path(r'^no-tag/$', TaggedObjectList.as_view(model=Article)), + re_path(r'^no-query-no-model/$', TaggedObjectList.as_view()), + re_path(r'(?u)^(?P<tag>[^/]+)/$', TaggedObjectList.as_view(model=Article)), ]
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor