[英]How to setup MongoDB with Django
我已經關注了許多教程,該教程介紹了如何使用MongoDB設置Django項目,但是在運行測試命令時仍然遇到相同的錯誤:
python manage.py runsever
這是我一直關注的鏈接:
http://www.allbuttonspressed.com/blog/django/2010/05/MongoDB-backend-for-Django-nonrel-released
這是我從上述命令中得到的錯誤:
Validating models...
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x10d266210>>
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 91, in inner_run
self.validate(display_num_errors=True)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 266, in validate
num_errors = get_validation_errors(s, app)
File "/Library/Python/2.7/site-packages/django/core/management/validation.py", line 23, in get_validation_errors
from django.db import models, connection
File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 40, in <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "/Library/Python/2.7/site-packages/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Library/Python/2.7/site-packages/django/db/utils.py", line 92, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Library/Python/2.7/site-packages/django/db/utils.py", line 24, in load_backend
return import_module('.base', backend_name)
File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "build/bdist.macosx-10.8-intel/egg/django_mongodb_engine/__init__.py", line 13, in <module>
AttributeError: 'tuple' object has no attribute 'insert'
我不知道為什么這不起作用,理想情況下,我只希望數據庫設置專門用於存儲JSON文檔。 除了將Django與另一個適合存儲JSON信息的數據庫連接之外,還有其他更簡單的方法嗎?
為了澄清:
INSTALLED_APPS應該是元組。
他得到AttributeError: 'tuple' object has no attribute 'insert'
因為mongodb無法正確處理INSTALLED_APPS元組。 mongodb中的默認值為插入列表。 以前已經解決了此問題,但現在已經不復存在。
有建議:
有一個新的包叫做djongo與MongoDB的充分的NoSQL支持: - https://nesdis.github.io/djongo/
您不能在venv中安裝ist:
pip install djongo
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.