Ticket #8898: 8898-DateTimeField-r8966.diff

File 8898-DateTimeField-r8966.diff, 2.0 KB (added by mrmachine, 7 years ago)
  • django/forms/fields.py

     
    381381            # components: date and time.
    382382            if len(value) != 2:
    383383                raise ValidationError(self.error_messages['invalid'])
     384            if value[0] in EMPTY_VALUES and value[1] in EMPTY_VALUES:
     385                if self.required:
     386                    raise ValidationError(self.error_messages['required'])
     387                return value
    384388            value = '%s %s' % tuple(value)
    385389        for format in self.input_formats:
    386390            try:
  • tests/regressiontests/forms/fields.py

     
    619619>>> repr(f.clean(''))
    620620'None'
    621621
     622Regression test for #8898.
     623>>> f = DateTimeField(widget=SplitDateTimeWidget)
     624>>> f.clean(['', ''])
     625Traceback (most recent call last):
     626...
     627ValidationError: [u'This field is required.']
     628>>> f = DateTimeField(required=False, widget=SplitDateTimeWidget)
     629>>> f.clean(['', ''])
     630['', '']
     631
    622632# RegexField ##################################################################
    623633
    624634>>> f = RegexField('^\d[A-F]\d$')
  • AUTHORS

     
    239239    Eugene Lazutkin <http://lazutkin.com/blog/>
    240240    lcordier@point45.com
    241241    Jeong-Min Lee <falsetru@gmail.com>
     242    Tai Lee <real.human@mrmachine.net>
    242243    Jannis Leidel <jl@websushi.org>
    243244    Christopher Lenz <http://www.cmlenz.net/>
    244245    lerouxb@gmail.com
     
    278279    Aljosa Mohorovic <aljosa.mohorovic@gmail.com>
    279280    Ramiro Morales <rm0@gmx.net>
    280281    Eric Moritz <http://eric.themoritzfamily.com/>
    281     mrmachine <real.human@mrmachine.net>
    282282    Robin Munn <http://www.geekforgod.com/>
    283283    James Murty
    284284    msundstr
Back to Top