我正在使用mongodb和django.i创建应用程序无法找到任何其他方式将我的数据库与django连接。所以使用mongokit进行连接 我收到这个错误: -
命令提示符 -
python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_from_command_line(sys.argv)
File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/somya/Desktop/backup/admin_python/admin_app/models.py", line 24, in <module>
from django_mongokit import connection
File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/django_mongokit/__init__.py", line 3, in <module>
from shortcut import get_database, get_version, connection
File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/django_mongokit/shortcut.py", line 13, in <module>
connection = connections['mongodb'].connection
File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/django/db/utils.py", line 240, in __getitem__
backend = load_backend(db['ENGINE'])
File "/var/www/html/admin_python/orahienv/local/lib/python2.7/site-packages/django/db/utils.py", line 129, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'django_mongokit.mongodb' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
u'base', u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3'
Error was: cannot import name BaseDatabaseOperations
setting.py -
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'pom',
'USER': 'root',
'PASSWORD': 'root',
'HOST': 'localhost',
},
'mongodb': {
'ENGINE': 'django_mongokit.mongodb',
'NAME': 'pom',
},
}
点子列表: -
pip list
You are using pip version 6.0.8, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
amqp (1.4.9)
anyjson (0.3.3)
Babel (2.3.4)
backports.ssl-match-hostname (3.5.0.1)
beautifulsoup4 (4.5.1)
billiard (3.3.0.23)
bs4 (0.0.1)
celery (3.1.23)
certifi (2016.2.28)
Django (1.8)
django-bootstrap3 (9.0.0)
django-celery (3.1.17)
django-cors-headers (1.1.0)
django-crispy-forms (1.6.0)
django-datatable (0.2.0)
django-datatables-view (1.13.0)
django-flash (1.8)
django-mongokit (0.2.6)
django-picklefield (0.3.2)
djangorestframework (3.3.2)
flower (0.9.1)
futures (3.0.5)
kombu (3.0.35)
mongoengine (0.13.0)
mongokit (0.9.1.1)
MySQL-python (1.2.5)
numpy (1.11.1)
olefile (0.44)
pandas (0.18.1)
pip (6.0.8)
pycrypto (2.6.1)
pymongo (2.8)
python-dateutil (2.5.3)
python-memcached (1.57)
pytz (2016.1)
razorpay (0.2.0)
requests (2.9.1)
setuptools (12.0.5)
six (1.10.0)
tornado (4.2)
validate-email (1.3)
wheel (0.29.0)
xmltodict (0.10.2)
答案 0 :(得分:0)
django-mongokit 0.2.6于2013年发布,因此它不支持Django 1.8。
看起来您的导入错误has been fixed,但自那以后一直没有发布。
您可以尝试安装master分支。但是,您应该仔细考虑是否要将项目基于自2013年以来尚未发布的库。
# Install master branch
pip install git+git://github.com/peterbe/django-mongokit.git@master
# Or specify commit to install
pip install git+git://github.com/peterbe/django-mongokit.git@b7c10d41675055490a88f7a67f65728465545142