Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #19929 -- Improved error when MySQL doesn't have TZ definitions.

Thanks tomas_00 for the report.
  • Loading branch information...
commit 0c82b1dfc48b4870e8fbcfb782ae02cdca821e1f 1 parent cf30469
Aymeric Augustin authored February 28, 2013
4  django/db/models/sql/compiler.py
@@ -1057,6 +1057,10 @@ def results_iter(self):
1057 1057
                 # Datetimes are artifically returned in UTC on databases that
1058 1058
                 # don't support time zone. Restore the zone used in the query.
1059 1059
                 if settings.USE_TZ:
  1060
+                    if datetime is None:
  1061
+                        raise ValueError("Database returned an invalid value "
  1062
+                                         "in QuerySet.dates(). Are time zone "
  1063
+                                         "definitions installed?")
1060 1064
                     datetime = datetime.replace(tzinfo=None)
1061 1065
                     datetime = timezone.make_aware(datetime, self.query.tzinfo)
1062 1066
                 yield datetime
7  docs/ref/contrib/admin/index.txt
@@ -142,6 +142,13 @@ subclass::
142 142
     e.g. if all the dates are in one month, it'll show the day-level
143 143
     drill-down only.
144 144
 
  145
+    .. note::
  146
+
  147
+        ``date_hierarchy`` uses :meth:`QuerySet.datetimes()
  148
+        <django.db.models.query.QuerySet.datetimes>` internally. Please refer
  149
+        to its documentation for some caveats when time zone support is
  150
+        enabled (:setting:`USE_TZ = True <USE_TZ>`).
  151
+
145 152
 .. attribute:: ModelAdmin.exclude
146 153
 
147 154
     This attribute, if given, should be a list of field names to exclude from

0 notes on commit 0c82b1d

Please sign in to comment.
Something went wrong with that request. Please try again.