Ticket #3172: datetime_validation_fix_and_tests.patch
File datetime_validation_fix_and_tests.patch, 1.4 KB (added by , 18 years ago) |
---|
-
django_src/django/db/models/fields/__init__.py
437 437 Field.__init__(self, verbose_name, name, **kwargs) 438 438 439 439 def to_python(self, value): 440 if value is None: 441 return value 440 442 if isinstance(value, datetime.datetime): 441 443 return value.date() 442 444 if isinstance(value, datetime.date): … … 499 501 500 502 class DateTimeField(DateField): 501 503 def to_python(self, value): 504 if value is None: 505 return value 502 506 if isinstance(value, datetime.datetime): 503 507 return value 504 508 if isinstance(value, datetime.date): -
django_src/tests/modeltests/validation/models.py
146 146 >>> p.validate() 147 147 {'email': ['Enter a valid e-mail address.']} 148 148 149 # Make sure that Date and DateTime return validation errors and don't raise Python errors. 150 >>> Person(name='John Doe', is_child=True, email='abc@def.com').validate() 151 {'favorite_moment': ['This field is required.'], 'birthdate': ['This field is required.']} 152 149 153 """}