Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare Django Taggit Release 5.0.0 #873

Merged
merged 2 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Changelog

(Unreleased)
~~~~~~~~~~~~

5.0.0 (2023-10-24)
~~~~~~~~~~~~~~~~~~
* **Backwards icompatible:** Rename the (``content_type``, ``object_id``) index on ``TaggedItem``.
It is very unlikely for this to affect your code itself, and a migration will rename the index. This should not cause any downtime according to my research (Postgres does not lock the table for index renames, and Oracle holds a tiny lock to do it, and the change is only to the metadata, so is not dependent on table size).

Expand Down
11 changes: 1 addition & 10 deletions taggit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,2 @@
try:
import django
except ImportError:
# setup.py and docs do not have Django installed.
django = None

VERSION = (4, 0, 0)
VERSION = (5, 0, 0)
__version__ = ".".join(str(i) for i in VERSION)

if django and django.VERSION < (3, 2):
default_app_config = "taggit.apps.TaggitAppConfig"
21 changes: 4 additions & 17 deletions taggit/managers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import uuid
from operator import attrgetter

import django
from django.conf import settings
from django.contrib.contenttypes.fields import GenericRelation
from django.contrib.contenttypes.models import ContentType
Expand Down Expand Up @@ -610,7 +609,7 @@ def _get_mm_case_path_info(self, direct=False, filtered_relation=None):
pathinfos = []
linkfield1 = self.through._meta.get_field("content_object")
linkfield2 = self.through._meta.get_field(self.m2m_reverse_field_name())
if django.VERSION >= (4, 1) and not filtered_relation:
if not filtered_relation:
# Django >= 4.1 provides cached path_infos and reverse_path_infos properties
# to use in preference to get_path_info / get_reverse_path_info when not
# passing a filtered_relation
Expand Down Expand Up @@ -656,14 +655,14 @@ def _get_gfk_case_path_info(self, direct=False, filtered_relation=None):
filtered_relation,
)
]
if django.VERSION >= (4, 1) and not filtered_relation:
if not filtered_relation:
join2infos = linkfield.path_infos
else:
join2infos = linkfield.get_path_info(
filtered_relation=filtered_relation
)
else:
if django.VERSION >= (4, 1) and not filtered_relation:
if not filtered_relation:
join1infos = linkfield.reverse_path_infos
else:
join1infos = linkfield.get_reverse_path_info(
Expand Down Expand Up @@ -736,26 +735,14 @@ def get_joining_fields(self, reverse_join=False):
),
)

def _get_extra_restriction(self, alias, related_alias):
def get_extra_restriction(self, alias, related_alias):
extra_col = self.through._meta.get_field("content_type").column
content_type_ids = [
ContentType.objects.get_for_model(subclass).pk
for subclass in _get_subclasses(self.model)
]
return ExtraJoinRestriction(related_alias, extra_col, content_type_ids)

def _get_extra_restriction_legacy(self, where_class, alias, related_alias):
# this is a shim to maintain compatibility with django < 4.0
return self._get_extra_restriction(alias, related_alias)

# this is required to handle a change in Django 4.0
# https://docs.djangoproject.com/en/4.0/releases/4.0/#miscellaneous
# the signature of the (private) function was changed
if django.VERSION < (4, 0):
get_extra_restriction = _get_extra_restriction_legacy
else:
get_extra_restriction = _get_extra_restriction

def get_reverse_joining_columns(self):
# RemovedInDjango60Warning
# https://github.com/django/django/commit/8b1ff0da4b162e87edebd94e61f2cd153e9e159d
Expand Down
Loading