2012-05-09 26 views
2

我得到django-nonreldjangotoolbox並從GitHub mongodbenginesetting.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上談論一個線程的東西,但它說,這已經是固定的。

+0

你有Django的nonrel的普通安裝官方的安裝說明或您使用的例如buildout或virtualenv?從traceback看來,django正在從'/ Library/...'中使用,而djangotoolbox和django-mongodb-engine正在從'build/...'中使用。 – jhonkola

+0

我剛剛從github獲得這些源代碼(Django Djangotoolbox等),然後使用'sudo python setup.py install'來安裝它。沒有使用'virutalenv'。事情是'Django1.4'安裝到我安裝'python'的路徑中,其他人安裝到'/ build/...' – bxshi

+1

如果你使用了github的Django1.4倉庫,這可能不起作用。克隆django-nonrel回購。有關這方面的進一步討論,請參閱https://groups.google.com/d/topic/django-non-relational/Hj6hmX_2KIA/discussion。 – jhonkola

回答

1
+0

官方指南的django-nonrel已過期。這可能會導致一些關於插入元組的問題。所以我在github上找到了新的。我會嘗試使用virtualenv看看我能否解決它。 – bxshi

+0

仍然有這個問題。也許我會嘗試使用Linux作爲我的開發服務器。 – bxshi

+0

他們不過時。如果按照我所鏈接的說明進行操作,它應該會很好地工作。 –