网站 建设 后台管理程序,百度登录,做网站都去哪申请网址,wordpress 网站访问量网上中文版的djongo链接mongoDB基本都是抄袭州的先生大哥的文章。 文章成文比较久#xff0c;至少是2019年成文的了#xff0c;有一些情况发生了变化#xff0c;今天就自己测试的情况做一些记录。 本文成文日期为#xff1a;2023年3月2日#xff0c;请注意参考 废话不多说…网上中文版的djongo链接mongoDB基本都是抄袭州的先生大哥的文章。 文章成文比较久至少是2019年成文的了有一些情况发生了变化今天就自己测试的情况做一些记录。 本文成文日期为2023年3月2日请注意参考 废话不多说直接说我遇到的3个问题。
1.djongo驱动不识别
错误信息 django.core.exceptions.ImproperlyConfigured: ‘djongo’ isn’t an available database backend or couldn’t be imported. Check the above exception. To use ondjango.core.exceptions.ImproperlyConfigured: ‘djongo’ isn’t an available databasedjango.core.exceptions.ImproperlyConfigured: ‘djongo’ isn’t an available database backend or couldn’t be imported. Check the above exception. To use one of the built-in backends,django.core.exceptions.ImproperlyConfigured: ‘djongo’ isn’t an available database backend or couldn’t be imported. Check the above exception. To use one of the built-in backends, use ‘django.db.backends.XX X’, where XXX is one of: ‘mysql’, ‘oracle’, ‘postgresql’, ‘sqlite3’ 根据https://github.com/doableware/djongo/issues/594 中的MrYazdan大佬提示 pip install pytz 安装pytz这个包后该问题解决。
2.数据库链接错误
错误信息 NotImplementedError: Database objects do not implement truth value testing or bool(). Please compare with None instead: database is not None 另一个连接报错信息为 pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [WinError 10061] 由于目标计算机积极拒绝无法连接。, Timeout: 30s, Topology Description: TopologyDescription id: 64001613c2c8ebc2982285e6, topo logy_type: Unknown, servers: [ServerDescription (‘localhost’, 27017) server_type: Unknown, rtt: None, errorAutoReconnect(‘localhost:27017: [WinError 10061] 由于目标计算机积极拒绝无法连接。’)] 比较明显应该是地址配置错误了导致他还是去连接localhost的地址。 原因为djongo的配置参数变化了 DATABASES {default: {ENGINE: djongo,# 指定具体的数据库还是用NAMENAME: your-db-name,ENFORCE_SCHEMA: False,# 对比州大佬使用的时候host被整合进了这个client中CLIENT: {host: host-name or ip address,port: port_number,username: db-username,password: password,# 该参数好像不是用来指定数据库名称具体什么作用我没有研究。authSource: db-name,authMechanism: SCRAM-SHA-1},LOGGING: {version: 1,loggers: {djongo: {level: DEBUG,propagate: False, }},},}}再看一眼州大佬给出的配置
# 旧配置参考当前版本djongo:1.3.6以无法使用
DATABASES {default: {ENGINE: djongo,ENFORCE_SCHEMA: True,NAME: your-db-name,# 已经不能通过这种方式指定HOST: host-name or ip address,PORT: port_number,USER: db-username,PASSWORD: password,AUTH_SOURCE: db-name,AUTH_MECHANISM: SCRAM-SHA-1,REPLICASET: replicaset,SSL: ssl,SSL_CERTFILE: ssl_certfile,SSL_CA_CERTS: ssl_ca_certs,READ_PREFERENCE: read_preference}
}3.pymongo版本过高导致建表异常
错误信息 TypeError: ‘Collection’ object is not callable. If you meant to call the ‘update’ method on a ‘Collection’ object it is failing because no such method exists. NotImplementedError: Database objects do not implement truth value testing or bool(). Please compare with None instead: database is not None 将 Pymongo 降低版本至 3.12.1当前最新版本为pymongo-4.3.3 pip install pymongo3.12.1
4.最终依赖情况
Django 4.1.7
django-simpleui 2023.3.1
djongo 1.3.6
dnspython 2.3.0
pip 23.0.1
pymongo 3.12.1
pytz 2022.7.1
setuptools 67.4.0
sqlparse 0.2.4
tzdata 2022.7