From 0c82b1dfc48b4870e8fbcfb782ae02cdca821e1f Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Thu, 28 Feb 2013 17:35:13 +0100 Subject: Fixed #19929 -- Improved error when MySQL doesn't have TZ definitions. Thanks tomas_00 for the report. --- django/db/models/sql/compiler.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'django/db/models/sql') diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py index b9d25d98a1..7ddee9785c 100644 --- a/django/db/models/sql/compiler.py +++ b/django/db/models/sql/compiler.py @@ -1057,6 +1057,10 @@ class SQLDateTimeCompiler(SQLCompiler): # Datetimes are artifically returned in UTC on databases that # don't support time zone. Restore the zone used in the query. if settings.USE_TZ: + if datetime is None: + raise ValueError("Database returned an invalid value " + "in QuerySet.dates(). Are time zone " + "definitions installed?") datetime = datetime.replace(tzinfo=None) datetime = timezone.make_aware(datetime, self.query.tzinfo) yield datetime -- cgit v1.3