Commit 0d685990 authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

ability to bootstrapize django messages

parent aba81326
......@@ -2,6 +2,7 @@ import logging
from django import forms
from django import template
from import Message
from django.forms.utils import ErrorList
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext
......@@ -102,7 +103,18 @@ def bootstrap_core(object):
elif isinstance(object, ErrorList):
for error in object:
ret.append("""<div class="alert alert-danger">%s</div>""" % error.replace("\n", "<br/>"))
elif isinstance(object, Message):
message = object
level_tag = message.level_tag
if level_tag == "error":
level_tag = "danger"
elif level_tag == "debug":
level_tag = "default"
ret.append("""<div class="alert alert-%s">%s</div>""" % (
message.message.replace("\n", "<br/>"),
elif len(str(object)) > 0:
ret.append("""<div class="alert alert-danger">Can't bootstrapize object of class %s</div>""" %
return ret
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment