This commit is contained in:
Ross
2025-12-05 22:04:09 +00:00
parent 3b920e819e
commit 5de97c5ee0
4 changed files with 10 additions and 5 deletions
+7 -2
View File
@@ -140,7 +140,10 @@ def card_delete(request, pk):
if request.method == 'POST':
card.delete()
if is_htmx(request):
return HttpResponse(status=204)
# Return an empty 200 response so HTMX can replace the
# targeted element (e.g. via `hx-swap="outerHTML"`) and
# remove it from the DOM immediately.
return HttpResponse('')
return redirect('cards:list')
return HttpResponseBadRequest('Only POST allowed')
@@ -197,7 +200,9 @@ def background_delete(request, pk):
bg = get_object_or_404(BackgroundImage, pk=pk)
bg.delete()
if is_htmx(request):
return HttpResponse(status=204)
# See comment in `card_delete`: return empty body so HTMX can
# remove the corresponding element via `hx-swap="outerHTML"`.
return HttpResponse('')
return redirect('cards:backgrounds')