Skip to content

Commit

Permalink
Merge pull request #927 from garrettc/fix-querystring-bug
Browse files Browse the repository at this point in the history
Fix bug with merge form action when querystring is present.
  • Loading branch information
rtpg authored Nov 5, 2024
2 parents e41b5fc + 9163b08 commit ee3d2d1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
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

0 comments on commit ee3d2d1

Please sign in to comment.