[Django]-Django outputting errorlist as string instead of html

4👍

You need to mark the string as “safe”, i.e. this:

return '<div class="test">%s</div>' % ''.join(['<div class="error">%s</div>' % e for e in self])

should be

return mark_safe('<div class="test">%s</div>' % ''.join(['<div class="error">%s</div>' % e for e in self]))

where mark_safe comes from:

from django.utils.safestring import mark_safe

Leave a comment