Messages does not render in template

Hi,
I am facing a problem with messages. When I use messages.success(request,“Message”) outside of the if where I check for POST message then message has been diplayed, but when I do this inside of the if then it doesn’t show up. When I checked network page inside of dev tools I can see that messages are included inside of the response, but it does not “reload” a website. Is there any mechanism/possibility to show those messages to user after “second” request.

TLDR:
I load a website and messages works.
I click a button that send a POST request.
Response from server contains defined messages.
Messages does not have been rendered.

Welcome @Rydzzu !

I think we’re going to need more details to try to help you here.

Does this mean you’re using some kind of AJAX request to request the page? If so, then it’s up to your JavaScript to inject the messages back into your page.

Please explain more about how you’re issuing these requests and handling the responses.

Exactly. I am using XMLHttpRequest for handling POST requests. I thought maybe there is any mechanism for handling this. Unfortunately like you said so, I have to implement it by using JS. Thank you :stuck_out_tongue:

Side note: This is precisely a type of situation where HTMX is fantastic.

1 Like

:open_mouth: I didn’t know about this project. Maybe I will try to rewrite it with this tool. Thanks !