diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 267d05af..20889d8c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -6,6 +6,7 @@ Changelog * Add an admin command to remove orphaned tags * Remove support for Python 3.8 +* Fix an issue where the admin merge tag form redirect would fail when querystrings are present inside the URL 6.1.0 (2024-09-29) ~~~~~~~~~~~~~~~~~~ diff --git a/taggit/admin.py b/taggit/admin.py index 7d0847bb..0f975e89 100644 --- a/taggit/admin.py +++ b/taggit/admin.py @@ -39,12 +39,11 @@ def render_tag_form(self, request, queryset): self.message_user(request, "Please select at least one tag.") return redirect(request.get_full_path()) + # set the selected tags into the session, to be used later selected_tag_ids = ",".join(selected) - redirect_url = f"{request.get_full_path()}merge-tags/" - request.session["selected_tag_ids"] = selected_tag_ids - return redirect(redirect_url) + return redirect("admin:taggit_tag_merge_tags") def merge_tags_view(self, request): selected_tag_ids = request.session.get("selected_tag_ids", "").split(",") diff --git a/tests/test_admin.py b/tests/test_admin.py index d36a6249..4daa3044 100644 --- a/tests/test_admin.py +++ b/tests/test_admin.py @@ -59,6 +59,7 @@ def test_tag_merging(self): ) # we're redirecting self.assertEqual(response.status_code, 302) + self.assertEqual(response.url, reverse("admin:taggit_tag_merge_tags")) # make sure what we expected got into the session keys assert "selected_tag_ids" in self.client.session.keys() self.assertEqual(