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

Cannot do bulk deletions in django with htmx 2 #3181

Open
GEORGES-DTECH opened this issue Feb 11, 2025 · 1 comment
Open

Cannot do bulk deletions in django with htmx 2 #3181

GEORGES-DTECH opened this issue Feb 11, 2025 · 1 comment

Comments

@GEORGES-DTECH
Copy link

The code below is working with htmx 1 and not 2
hx-delete="{%url 'delete-loans'%}" hx-target="#container" hx-indicator="#spinner"

@login_required
def delete_loans(request):
data = request.body.decode("utf-8")
q = QueryDict(data, mutable=True)
checked_ids = q.getlist("ids")

Transaction.objects.filter(pk__in=checked_ids).delete()
return redirect(reverse("loans"))
@GEORGES-DTECH GEORGES-DTECH changed the title Cannot do bulk deletions on htmx 2 Cannot do bulk deletions in django with htmx 2 Feb 11, 2025
@geoffrey-eisenbarth
Copy link
Contributor

geoffrey-eisenbarth commented Feb 11, 2025

HTMX changed DELETE to use URL params instead of the request body (see migration guide].

Looks like you're using Django, so the data will be in request.GET (which probably should have been named request.QUERY but 🤷‍♂️).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants