diff --git a/sample_taggit/settings.py b/sample_taggit/settings.py index 0cc0de84..bd1183fe 100644 --- a/sample_taggit/settings.py +++ b/sample_taggit/settings.py @@ -76,9 +76,17 @@ # https://docs.djangoproject.com/en/5.0/ref/settings/#databases DATABASES = { + # "default": { + # "ENGINE": "django.db.backends.sqlite3", + # "NAME": BASE_DIR / "db.sqlite3", + # } "default": { - "ENGINE": "django.db.backends.sqlite3", - "NAME": BASE_DIR / "db.sqlite3", + "ENGINE": "django.db.backends.postgresql", + "NAME": "sample_taggit_app", + "USER": "postgres", + "PASSWORD": "postgres", + "HOST": "localhost", + "PORT": "5432", } } diff --git a/taggit/admin.py b/taggit/admin.py index 7dc9df6f..8d8084ec 100644 --- a/taggit/admin.py +++ b/taggit/admin.py @@ -32,9 +32,7 @@ def get_urls(self): ] return custom_urls + urls - @admin.action( - description="Merge selected tags" - ) + @admin.action(description="Merge selected tags") def render_tag_form(self, request, queryset): selected = request.POST.getlist(admin.helpers.ACTION_CHECKBOX_NAME) if not selected: @@ -42,21 +40,14 @@ def render_tag_form(self, request, queryset): return redirect(request.get_full_path()) selected_tag_ids = ",".join(selected) - redirect_url = ( - f"{request.get_full_path()}merge-tags/?selected_tags={selected_tag_ids}" - ) + redirect_url = f"{request.get_full_path()}merge-tags/" + + request.session["selected_tag_ids"] = selected_tag_ids return redirect(redirect_url) def merge_tags_view(self, request): - if request.method == "GET": - selected_tag_ids = request.GET.get("selected_tags", "").split(",") - - # store selected_tag_ids in session data until they are merged - request.session["selected_tag_ids"] = selected_tag_ids - else: - selected_tag_ids = request.session.get("selected_tag_ids", []) - + selected_tag_ids = request.session.get("selected_tag_ids", "").split(",") if request.method == "POST": form = MergeTagsForm(request.POST) if form.is_valid(): @@ -71,6 +62,7 @@ def merge_tags_view(self, request): tagged_item.save() # tag.delete() #this will delete the selected tags after merge + self.message_user(request, "Tags have been merged") # clear the selected_tag_ids from session after merge is complete request.session.pop("selected_tag_ids", None) return redirect("..") @@ -84,4 +76,3 @@ def merge_tags_view(self, request): } return render(request, "admin/taggit/merge_tags_form.html", context) -