Reputation: 791
i tried to TruncDay in django to turn date into day format , i use mysql
version 8.0
with windows 10
this my settings.py
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
date = models.DateTimeField(auto_now_add=True)
MyModel.objects.annotate(day=TruncDay('date'))#others
and i tried to run mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql;
but it raise this error while i run this command in mysql shell
ERROR: 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql' at line 1
i also downloaded times files https://dev.mysql.com/downloads/timezones.html
and also my django project raise this error also
Database returned an invalid datetime value. Are time zone definitions for your database installed?
Upvotes: 2
Views: 5354
Reputation: 11
After executing mysql_tzinfo_to_sql
, you need to refresh the mysql cache, otherwise it will have no effect!
Upvotes: 0
Reputation: 31
I'm using Windows 10 and MySQL Server 8.0 What I did was:
USE mysql;
to the first line.Upvotes: 0
Reputation: 438
Just change the settings.py from
USE_TZ = True
to
USE_TZ = False
This worked for me.
Upvotes: 0
Reputation: 114
Database returned an invalid datetime value. Are time zone definitions for your database installed?
I got the same error after upgrading django from 2.2 to 3.2 and this was the first stack overflow question I found.
For me the following fixed the error: https://stackoverflow.com/a/21571350/10162645
Upvotes: 1