Skip to content

Instantly share code, notes, and snippets.

@hgdeoro
Created January 24, 2012 16:22
Show Gist options
  • Save hgdeoro/1670938 to your computer and use it in GitHub Desktop.
Save hgdeoro/1670938 to your computer and use it in GitHub Desktop.
Custom Django filter to convert message levels to valid blueprint css
# -*- coding: utf-8 -*-
from django import template
from django.contrib import messages
register = template.Library()
LEVEL_TO_CSS = {
messages.ERROR: "error",
messages.WARNING: "notice",
messages.SUCCESS: "success",
messages.INFO: "info",
}
@register.filter(name='level2css')
def level2css(message):
return LEVEL_TO_CSS.get(message.level, "info")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment