I was looking something similar to Bootstrap Alerts for using as flash message and came up with this - Flask-Toastr. I tried to import it but saw that it's not present so thought of installing it but got no command for installing via conda
. Can anyone provide me the command for installation ?
Or can you give a better flash message display style.
2 Answers
Why not just implement this natively. Flask supports a Flashing with Categroies...
You could pass the bootstrap class name as the category string:
flash(u'You are about to delete everything!', 'alert-danger')
Then handle this in the template. This is with Bootstrap 4.3's syntax for alerts...
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert {{category}}" role="alert">
{{message}}
</div>
{% endfor %}
{% endif %}
{% endwith %}
This saves on introducing another dep for something simple.
-
I am currently using bootstrap alert but looking to try something new so I came up with this Oct 5, 2019 at 0:14
-
1@BarefacedBear The
u
in front of the string was intentional. See this question for an explanation. Oct 5, 2019 at 0:26 -
I wish to use bootstrap toast instead of alerts. I replaced the contents with code for toast but does not seem to be working. Any idea ? Mar 27, 2022 at 18:56
If a package is not available from conda or Anaconda.org, you may be able to find and install the package via conda-forge or with another package manager like pip, as stated in the docs.