For example, before redirect, I used
messages.add_message(request, messages.INFO, 'You have successfully updated your listing.')
Then the message will be automatically displayed after redirection, however the message will never disappear, may I know how to hide it after few seconds?
Thanks!!!
You need to write javascript code, use window setTimeout()
method to hide message after some time.
// suppose the `id` attribute of element is `message_container`.
var message_ele = document.getElementById("message_container");
setTimeout(function(){
message_ele.style.display = "none";
}, 3000);
// Timeout is 3 sec, you can change it
Put this code inside
base.html
at the bottom inside<script>
tag, so whenever page reloaded after 3 sec it will make your message disappear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With