我創建了使用Mongo的數據庫Django的web應用程序,我Connet的與pymongo如何爲mongodb配置settings.py?
def load_database():
mongo = pymongo.Connection('127.0.0.1')
db = mongo['database']
到蒙戈當我試圖加載我的web應用程序,我得到錯誤
Exception Type:
ImproperlyConfigured
Exception Value:
settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.
Exception Location:
Python-2.7/lib/python2.7/site-packages/django/db/backends/dummy/base.py in complain, line 15
它看起來是settings.py配置錯誤,這是我的settings.py:
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or
'NAME': '', # Or path to database file if using sqlite3.
# The following settings are not`enter code here` used with sqlite3:
'USER': '',
'PASSWORD': '',
'HOST': '', # Empty for localhost through domain sockets or '
'PORT': '', # Set to empty string for default.
}
}
有人可以告訴我什麼是錯?當我加載不認識mongo的主頁時,只有靜態文件加載得很好,當我點擊hotempage上的mongo數據庫中的數據並打印出數據時,我得到這個錯誤。另外我試過python manage.py syncdb,但得到錯誤:不正確配置:settings.DATABASES配置不當。請提供ENGINE值。檢查設置文檔以獲取更多細節。
我用pymongo直接寫給但看起來這個問題是不是在pymongo,我只是推測我們現在,我使用的request.session,所以這就是爲什麼我得到錯誤,使用海寧變量我需要syncdb數據庫,你知道該怎麼做嗎? – ivan
確定您需要指定數據庫後端來存儲會話數據。您可以使用MongoDB來使用[Mongoengine(請參閱第6.4節)](http://mongoengine-odm.readthedocs.org/en/latest/django.html#sessions)。 –
當我在settings.py SESSION_ENGINE添加=「mongoengine.django.sessions」,我得到錯誤導入錯誤 異常值:\t 無模塊命名mongoengine.django.sessions – ivan