Skip to content

Instantly share code, notes, and snippets.

@dimitrov
Created April 26, 2015 20:30
Show Gist options
  • Save dimitrov/d099e927fc6276c9505e to your computer and use it in GitHub Desktop.
Save dimitrov/d099e927fc6276c9505e to your computer and use it in GitHub Desktop.
Bootstrap Alerts for Django
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }} alert-dismissible text-center" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong>{% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}Error{% else %}{{ message.tags|title }}{% endif %}!</strong> {{ message }}
</div>
{% endfor %}
{% endif %}
from django.contrib.messages import constants as messages
MESSAGE_TAGS = {
messages.ERROR: 'danger'
}
@richardfogaca
Copy link

Very nice, thanks!

@leandrocl2005
Copy link

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment