from django import newforms as forms
class PrettyBaseForm (forms.BaseForm):
class NormalRowFormatter(object):
def _error_class(self, errors):
if errors:
return ' class="error"'
else:
return ''
def __mod__(self, d):
return u'
' % self._error_class(d['errors']) \
+ u'
%(label)s
%(field)s%(errors)s%(help_text)s
' % d
def as_table(self):
return self._html_output(
PrettyBaseForm.NormalRowFormatter(),
u'