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

Fix bug with merge form action when querystring is present. #927

Merged
merged 2 commits into from
Nov 5, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
~~~~~~~~~~~~~~~~~~
Expand Down
5 changes: 2 additions & 3 deletions taggit/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(",")
Expand Down
1 change: 1 addition & 0 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading