我一直在使用 Django 1.3 non-rel 和 django-mongodb_engine 0.4。正在使用的 Mongodb 版本是 1.8.2,一切正常。最近我尝试升级到 mongodb 2.4.2(latest stable) 版本并遇到以下问题。
同步数据库后,我得到以下异常:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line
438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line
379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 191,
in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 220,
in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 351,
in handle
return self.handle_noargs(**options)
File "/usr/local/lib/python2.7/dist-
packages/django/core/management/commands/syncdb.py", line 90, in handle_noargs
sql, references = connection.creation.sql_create_model(model, self.style, seen_models)
File "/usr/local/lib/python2.7/dist-packages/django_mongodb_engine/creation.py", line
142, in sql_create_model
self.connection.get_collection(model._meta.db_table, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django_mongodb_engine/base.py", line 98,
in get_collection
collection = self.collection_class(self.database, name, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 108, in
__init__
self.__create(kwargs)
File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 119, in
__create
self.__database.command("create", self.__name, **options)
File "/usr/local/lib/python2.7/dist-packages/pymongo/database.py", line 393, in command
msg, allowable_errors)
File "/usr/local/lib/python2.7/dist-packages/pymongo/helpers.py", line 144, in
_check_command_response
raise OperationFailure(msg % details["errmsg"])
pymongo.errors.OperationFailure: command SON([('create', u'auth_permission'), ('max',
False), ('capped', False), ('size', 0.0)]) failed: exception: create collection invalid
size spec
与以前的 mongodb 版本(< 1.8)相比,异常的原因似乎是 mongo 2.X 版本之间的某种不兼容。
从错误中可以看出,有没有办法解决这个有上限/无上限的集合创建问题?