django.axes setup

Hi dear people in here,

I#m trying to set up django.axes for my project. I’ve done everything like described in

python check reports no failures, after migration the necessary tables are in database, but nothing is logged at all. And when toggling the Access logs in Django admin, i get an
Database returned an invalid datetime value. Are time zone definitions for your database installed ValueError.

My settings on this topic in are

TIME_ZONE = 'Europe/Berlin'
USE_I18N = True
USE_TZ = True
USE_L10N = True

Any idea where to search for the problem?

What database engine are you using?

By searching the source code for “Database returned an invalid datetime”, it appears to be coming from django.db.models.functions.datetime.TruncBase.convert_value, referencing an attribute has_zoneinfo_database.

Then searching the source code for “has_zoneinfo_database”, you can see that this defaults to True, except for the mysql backend - where it is set to False if “timezone isn’t loaded into the mysql.time_zone table”. (See django.db.backends.mysql.base.DatabaseWrapper.mysql_server_data.)

So if you’re using MySQL, then this likely is what you need to fix.

1 Like

Of course it is MySQL :see_no_evil:

so, after knowing about that, it was no real problem anymore. maybe it should be mantioned in the installation part of django axes as side note that mySQL needs special care :slight_smile: