diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 8b000d3c2a..c36cd9808d 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -406,7 +406,10 @@ class DateField(Field): if isinstance(value, datetime.date): return value validators.isValidANSIDate(value, None) - return datetime.date(*time.strptime(value, '%Y-%m-%d')[:3]) + 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':