I have been using the Django Messaging Framework to display messages to a user in the template.
I am outputting them to the template like this:
A bit of a faff, but you could probably achieve this by adding a custom template context processor (cf. https://docs.djangoproject.com/en/dev/ref/templates/api/ ) -- something like
def collect_error_messages(request):
messages = get_messages(request)
error_messages = [ m for m in messages if 'error' in m.tags]
return {'error_messages': error_messages}
then add that to your TEMPLATE_CONTEXT_PROCESSORS list in settings.py, and then in templates you can do:
{% for message in error_messages %}
- {{ message }}
{% endfor %}
You could do a variation on the same to build a dict mapping error level to message, and then iterate through each dict.