gpt4 book ai didi

python - django-nonrel syncdb 和 mongodb : pymongo. 错误。OperationFailure

转载 作者:IT老高 更新时间:2023-10-28 13:22:01 37 4
gpt4 key购买 nike

我正在使用 django-nonrel 和 mongodb-engine 运行 python manage.py syncdb 时出现以下错误:

Traceback (most recent call last):
File "manage.py", line 22, in <module> execute_from_command_line(sys.argv)
File "/Users/<user>/site/qmcdb/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/Users/<user>/site/qmcdb/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/<user>/site/qmcdb/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/<user>/site/qmcdb/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/Users/<user>/site/qmcdb/lib/python2.7/site-packages/django/core/management/base.py", line 415, in handle
return self.handle_noargs(**options)
File "/Users/<user>/site/qmcdb/lib/python2.7/site-packages/django/core/management/commands/syncdb.py", line 147, in handle_noargs
index_sql = connection.creation.sql_indexes_for_model(model, self.style)
File "/Users/<user>/site/qmcdb/lib/python2.7/site-packages/django_mongodb_engine/creation.py", line 49, in sql_indexes_for_model
self._handle_oldstyle_indexes(ensure_index, meta)
File "/Users/<user>/site/qmcdb/lib/python2.7/site-packages/django_mongodb_engine/creation.py", line 116, in _handle_oldstyle_indexes
sparse=field.name in sparse_indexes)
File "/Users/<user>/site/qmcdb/lib/python2.7/site-packages/django_mongodb_engine/creation.py", line 42, in ensure_index
return collection.ensure_index(*args, **kwargs)
File "/Users/<user>/site/qmcdb/lib/python2.7/site-packages/pymongo/collection.py", line 1420, in ensure_index
self.__create_index(keys, kwargs)
File "/Users/<user>/site/qmcdb/lib/python2.7/site-packages/pymongo/collection.py", line 1298, in __create_index
sock_info, cmd, read_preference=ReadPreference.PRIMARY)
File "/Users/<user>/site/qmcdb/lib/python2.7/site-packages/pymongo/collection.py", line 208, in _command
read_concern=read_concern)
File "/Users/<user>/site/qmcdb/lib/python2.7/site-packages/pymongo/pool.py", line 239, in command
read_concern)
File "/Users/<user>/site/qmcdb/lib/python2.7/site-packages/pymongo/network.py", line 102, in command
helpers._check_command_response(response_doc, None, allowable_errors)
File "/Users/<user>/site/qmcdb/lib/python2.7/site-packages/pymongo/helpers.py", line 205, in _check_command_response
raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: The field 'sparse' is not valid for an _id index specification. Specification: { ns: "qmcdb_mongodb.django_admin_log", v: 2, sparse: false, unique: true, name: "_id_1", key: { _id: 1 } }

我不知道出了什么问题。我一直试图让 mongodb 与 django 一起工作,但我遇到了很多问题。我的设置.py:

DATABASES = {
'default': {
'ENGINE': 'django_mongodb_engine',
'NAME': 'qmcdb_mongodb',
'PORT': 27017,
'HOST': 'localhost'
}
}

我希望我已经发布了足够的背景信息。非常感谢任何帮助。

最佳答案

尝试使用 3.2 版本的 Mongo 数据库,mongoengine 和 Mongo Server 3.4 存在一些问题

关于python - django-nonrel syncdb 和 mongodb : pymongo. 错误。OperationFailure,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41094029/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com