Commit 0d14498e authored by Adrian Holovaty's avatar Adrian Holovaty
Browse files

Improved DateField.to_python() to catch invalid dates like Feb. 31

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3242 bcc190cf-cafb-0310-a4f2-bffc1f526a37
parent c9032ab0
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -406,7 +406,10 @@ class DateField(Field):
        if isinstance(value, datetime.date):
            return value
        validators.isValidANSIDate(value, None)
        try:
            return datetime.date(*time.strptime(value, '%Y-%m-%d')[:3])
        except ValueError:
            raise validators.ValidationError, gettext('Enter a valid date in YYYY-MM-DD format.')

    def get_db_prep_lookup(self, lookup_type, value):
        if lookup_type == 'range':