Closed Domejko closed 4 weeks ago
@TreyWW When we return error message with status 404 we get thrown into a loop. One of solutions to avoid this and display error toast message to a user is:
messages.error(request, 'Client not found')
return render(request, "pages/clients/dashboard/_table.html", {"delete": True})
If returning a 404 status is essential I can further investigate that issue. Let me know.
As it comes to JsonResponse
from what I have searched we don't have a JS to handle that. We would need a function that will take message from JsonResponse
and return it to the user as a error toast message.
If returning a 404 status is essential I can further investigate that issue. Let me know.
As it comes to
JsonResponse
from what I have searched we don't have a JS to handle that. We would need a function that will take message fromJsonResponse
and return it to the user as a error toast message.
Yeah this is a big issue throughout the project. We, like you say, have two solutions.
I'm completely happy with option 1 for now though, feel free to just return a message and let the row delete, since the client is "non existent" anyways. It's just I find errors like this mean I've messed up (developer), that a bug caused it (generally at least).
So yeah, fine by me.
I understand. I will implement and push 1st solution for the time been and in some spare time I will try to work on the 2nd solution but it might take a while since I don't have experience with JS.
Update: For option 2 with deleting content, I just checked the HTMX docs and we can actually send off a HX-Reswap and HX-Retarget to send off the notifications still! It would need some django work, but no JS! Woo!
I can provide more details later, just about to head home.
@Domejko sorry about the delay. Could you run py manage.py lint
@TreyWW no problem. Linting and formatting have been fixed now.
What about that HX-Reswap
and HX-Retarget
you have some more details on that ?
Great PR, thanks @Domejko! :)
Description
Regarding #386
TODO:
{% component "messages_list" %}
at the end of _rows.html then message about successful creation of client gets 'bugged' and it just blinks for split of second. I don't know much about HTML so I'm learning on the fly.Checklist
What type of PR is this?
Added/updated tests?
Related PRs, Issues etc