我得到django-nonrel
,djangotoolbox
并从GitHub mongodbengine
和setting.py
运行执行syncdb是如下:不能使用Django和MongoDB
DATABASES = {
'default': {
'ENGINE': 'django_mongodb_engine', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'admin', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
)
ROOT_URLCONF = 'ptl.urls'
TEMPLATE_DIRS = ('/Users/bxshi/PycharmProjects/ptl/templates',)
INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.sessions',
)
除了settings.py
,我没有任何其他.py
文件在我的项目。
我得到的错误是:
BaoxuShis-MacBook:ptl bxshi$ python manage.py syncdb
Creating tables ...
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 351, in handle
return self.handle_noargs(**options)
File "/Library/Python/2.7/site-packages/django/core/management/commands/syncdb.py", line 109, in handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
File "/Library/Python/2.7/site-packages/django/core/management/sql.py", line 190, in emit_post_sync_signal
interactive=interactive, db=db)
File "/Library/Python/2.7/site-packages/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "/Library/Python/2.7/site-packages/django/contrib/contenttypes/management.py", line 11, in update_contenttypes
content_types = list(ContentType.objects.filter(app_label=app.__name__.split('.')[-2]))
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 84, in __len__
self._result_cache.extend(self._iter)
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line 275, in iterator
for row in compiler.results_iter():
File "build/bdist.macosx-10.7-intel/egg/djangotoolbox/db/basecompiler.py", line 335, in results_iter
File "build/bdist.macosx-10.7-intel/egg/djangotoolbox/db/basecompiler.py", line 430, in build_query
File "build/bdist.macosx-10.7-intel/egg/django_mongodb_engine/compiler.py", line 160, in add_filters
File "build/bdist.macosx-10.7-intel/egg/django_mongodb_engine/compiler.py", line 168, in add_filters
ValueError: need more than 3 values to unpack
我觉得与这个错误有关mongodbengine,在BBS上谈论一个线程的东西,但它说,这已经是固定的。
你有Django的nonrel的普通安装官方的安装说明或您使用的例如buildout或virtualenv?从traceback看来,django正在从'/ Library/...'中使用,而djangotoolbox和django-mongodb-engine正在从'build/...'中使用。 – jhonkola
我刚刚从github获得这些源代码(Django Djangotoolbox等),然后使用'sudo python setup.py install'来安装它。没有使用'virutalenv'。事情是'Django1.4'安装到我安装'python'的路径中,其他人安装到'/ build/...' – bxshi
如果你使用了github的Django1.4仓库,这可能不起作用。克隆django-nonrel回购。有关这方面的进一步讨论,请参阅https://groups.google.com/d/topic/django-non-relational/Hj6hmX_2KIA/discussion。 – jhonkola