Skip to content

Instantly share code, notes, and snippets.

@swasher
swasher / messages.html
Last active July 19, 2017 20:19 — forked from DmytroLitvinov/messages.html
[Django middleware for AJAX messages] Middleware for JSON responses. It adds to each JSON response array with messages from django.contrib.messages framework. It allows handle messages on a page with javascript. Django 1.10. #tags: django, python, ajax
<div id="messages">
{% for message in messages %}
<div {% if message.tags %}class="alert alert-dismissable alert-{{ message.tags }}"{% endif %}>
<a class="close" data-dismiss="alert" href="#">&times;</a>
{{ message }}
</div>
{% endfor %}
</div>