Django-REST:数据库驱动程序不支持现代数据时间类型

Django-REST: The database driver doesn't support modern datatime types

我正在尝试使用 Debian 上的 Django Rest 休息 API, 但是当我 运行 命令 "python3 manage.py migrate" 抛出这个异常时

错误:数据库驱动程序不支持现代数据时间类型。”) django.core.exceptions.ImproperlyConfigured: 数据库驱动程序不支持现代数据时间类型。

已安装:

msodbcsql17 is already the newest version (17.3.1.1-1).
freetds-bin is already the newest version (0.91-6.1+b4).
freetds-dev is already the newest version (0.91-6.1+b4).
tdsodbc is already the newest version (0.91-6.1+b4).
unixodbc-dev is already the newest version (2.3.7).
unixodbc is already the newest version (2.3.7).

文件:odbc.ini

[MYSERVER]
Description         = Django SQLServer
Driver              = FreeTDS
Trace               = Yes
TraceFile           = /tmp/sql.log
Database            = DjangoDB
Servername          = MYSERVER
UserName            = sa
Password            = *******
Port                = 1433
Protocol            = 8.0

文件:odbcinst.ini

[FreeTDS]
Description=FreeTDS Driver for Linux & MSSQL on Win32
Driver=/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
Setup =/usr/lib/x86_64-linux-gnu/odbc/libtdsodbc.so
UsageCount=1

[ODBC Driver 17 for SQL Server]
Description=Microsoft ODBC Driver 17 for SQL Server
Driver=/opt/microsoft/msodbcsql17/lib64/libmsodbcsql-17.3.so.1.1
UsageCount=1

文件:freetds.conf

[global]
# TDS protocol version
tds version = 8.0

[MYSERVER]
host = localhost
port = 1433
tds version = 8.0

问题出在您的 TDS 版本上。 8.0 版实际上不是一个有效的版本,尽管 Internet 上存在很多不好的建议。这有很多原因,但 8.0 版实际上映射到 TDS 7.1 版,这是在 Microsoft 在 SQL Server 2008 中添加新的日期和时间字段类型之前。请参见此处的脚注:

https://www.freetds.org/userguide/tdshistory.htm

您是 运行 相当旧的 FreeTDS (0.91) 版本。它仅支持 SQL Server 2005 中引入的 TDS 7.2 版。我建议升级您的 FreeTDS 版本,并使用 TDS 7.3 版。详情在这里:

https://www.freetds.org/userguide/choosingtdsprotocol.htm

另一种选择是使用您似乎已经安装的 MS ODBC 驱动程序,它 up-to-date 比您拥有的 FreeTDS 版本要多得多。

祝你好运!