Created
November 2, 2012 06:06
-
-
Save yxkelan/3998989 to your computer and use it in GitHub Desktop.
Customizing the error list format Django
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In form.py | |
from django.forms.util import ErrorList | |
from django.utils.safestring import mark_safe | |
class ErrorListMsg(ErrorList): | |
def __unicode__(self): | |
return self.as_msg() | |
def as_msg(self): | |
if not self: return u'' | |
return mark_safe(u'\n'.join([u'<span class="red">%s</span>' % e for e in self])) | |
#In view.py | |
file_form = form_class(request.POST,request.FILES,error_class=ErrorListMsg) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment