Fixed #19929 -- Improved error when MySQL doesn't have TZ definitions.
Thanks tomas_00 for the report.
This commit is contained in:
parent
cf30469164
commit
0c82b1dfc4
|
@ -1057,6 +1057,10 @@ class SQLDateTimeCompiler(SQLCompiler):
|
||||||
# Datetimes are artifically returned in UTC on databases that
|
# Datetimes are artifically returned in UTC on databases that
|
||||||
# don't support time zone. Restore the zone used in the query.
|
# don't support time zone. Restore the zone used in the query.
|
||||||
if settings.USE_TZ:
|
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 = datetime.replace(tzinfo=None)
|
||||||
datetime = timezone.make_aware(datetime, self.query.tzinfo)
|
datetime = timezone.make_aware(datetime, self.query.tzinfo)
|
||||||
yield datetime
|
yield datetime
|
||||||
|
|
|
@ -142,6 +142,13 @@ subclass::
|
||||||
e.g. if all the dates are in one month, it'll show the day-level
|
e.g. if all the dates are in one month, it'll show the day-level
|
||||||
drill-down only.
|
drill-down only.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
``date_hierarchy`` uses :meth:`QuerySet.datetimes()
|
||||||
|
<django.db.models.query.QuerySet.datetimes>` internally. Please refer
|
||||||
|
to its documentation for some caveats when time zone support is
|
||||||
|
enabled (:setting:`USE_TZ = True <USE_TZ>`).
|
||||||
|
|
||||||
.. attribute:: ModelAdmin.exclude
|
.. attribute:: ModelAdmin.exclude
|
||||||
|
|
||||||
This attribute, if given, should be a list of field names to exclude from
|
This attribute, if given, should be a list of field names to exclude from
|
||||||
|
|
Loading…
Reference in New Issue