I'd like to flash a message in a template, which there is a ton of information on, but I haven't seen any way to give it a custom name, which would allow it to have the appropriate class or id for styling. In Laravel:
webpage.php
@if (session()->has('login_success'))
<div id="loginFlash">{{ session('login_success') }}</div>
@endif
Where login_success
is defined before rendering the page
So far with Django:
webpage.html
{% for message in messages %}
<div id="{{ message.tags }}">
{{ message }}
</div>
{% endfor %}
But I can't get message.tags
to return a SINGLE custom value. For instance:
messages.add_message(self.request, messages.INFO, self.request.user.username, 'loginFlash')
This returns:
<div id="loginFlash info">
username
</div>
How to remove the second argument? It seems like all of the message
methods already specify at least one tag. Thanks so much!