Ticket #4471: remove_stars_from_errors.diff

File remove_stars_from_errors.diff, 1.8 KB (added by Grant Kelly <gkelly@…>, 17 years ago)
  • django/newforms/util.py

     
    2424        return u'<ul class="errorlist">%s</ul>' % ''.join([u'<li>%s%s</li>' % (k, v) for k, v in self.items()])
    2525
    2626    def as_text(self):
    27         return u'\n'.join([u'* %s\n%s' % (k, u'\n'.join([u'  * %s' % i for i in v])) for k, v in self.items()])
     27        return u'\n'.join([u' %s\n%s' % (k, u'\n'.join([u'  %s' % i for i in v])) for k, v in self.items()])
    2828
    2929class ErrorList(list):
    3030    """
     
    3939
    4040    def as_text(self):
    4141        if not self: return u''
    42         return u'\n'.join([u'* %s' % e for e in self])
     42        return u'\n'.join([u' %s' % e for e in self])
    4343
    4444class ValidationError(Exception):
    4545    def __init__(self, message):
  • tests/regressiontests/forms/tests.py

     
    20132013>>> p.errors.as_ul()
    20142014u'<ul class="errorlist"><li>first_name<ul class="errorlist"><li>This field is required.</li></ul></li><li>birthday<ul class="errorlist"><li>This field is required.</li></ul></li></ul>'
    20152015>>> print p.errors.as_text()
    2016 * first_name
    2017   * This field is required.
    2018 * birthday
    2019   * This field is required.
     2016 first_name
     2017  This field is required.
     2018 birthday
     2019  This field is required.
    20202020>>> p.cleaned_data
    20212021Traceback (most recent call last):
    20222022...
     
    20262026>>> p['first_name'].errors.as_ul()
    20272027u'<ul class="errorlist"><li>This field is required.</li></ul>'
    20282028>>> p['first_name'].errors.as_text()
    2029 u'* This field is required.'
     2029u' This field is required.'
    20302030
    20312031>>> p = Person()
    20322032>>> print p['first_name']
Back to Top