Django MongoDB问题 [英] Django MongoDB problem

查看:82
本文介绍了Django MongoDB问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的django应用程序在mysql上运行,但是当我尝试在mongodb上运行时却显示出错误

my django app run with mysql, but when i try with mongodb then show thie error

Traceback (most recent call last):
  File "manage.py", line 14, in <module>
    execute_manager(settings)
  File "/home/abdullah/django-trunk/django/core/management/__init__.py", line 442, in execute_manager
    utility.execute()
  File "/home/abdullah/django-trunk/django/core/management/__init__.py", line 379, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/abdullah/django-trunk/django/core/management/base.py", line 191, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/abdullah/django-trunk/django/core/management/base.py", line 209, in execute
    translation.activate('en-us')
  File "/home/abdullah/django-trunk/django/utils/translation/__init__.py", line 106, in activate
    return _trans.activate(language)
  File "/home/abdullah/django-trunk/django/utils/translation/trans_real.py", line 191, in activate
    _active.value = translation(language)
  File "/home/abdullah/django-trunk/django/utils/translation/trans_real.py", line 180, in translation
    default_translation = _fetch(settings.LANGUAGE_CODE)
  File "/home/abdullah/django-trunk/django/utils/translation/trans_real.py", line 157, in _fetch
    app = import_module(appname)
  File "/home/abdullah/django-trunk/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/home/abdullah/django-trunk/django/contrib/admin/__init__.py", line 3, in <module>
    from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
  File "/home/abdullah/django-trunk/django/contrib/admin/helpers.py", line 2, in <module>
    from django.contrib.admin.util import (flatten_fieldsets, lookup_field,
  File "/home/abdullah/django-trunk/django/contrib/admin/util.py", line 1, in <module>
    from django.db import models
  File "/home/abdullah/django-trunk/django/db/__init__.py", line 27, in <module>
    connection = connections[DEFAULT_DB_ALIAS]
  File "/home/abdullah/django-trunk/django/db/utils.py", line 82, in __getitem__
    conn = backend.DatabaseWrapper(db, alias)
  File "/usr/local/lib/python2.6/dist-packages/django_mongodb_engine-0.4.0-py2.6.egg/django_mongodb_engine/base.py", line 87, in __init__
    self.ops = DatabaseOperations(self)
  File "/usr/local/lib/python2.6/dist-packages/djangotoolbox-0.9.2-py2.6.egg/djangotoolbox/db/base.py", line 28, in __init__
    super(NonrelDatabaseOperations, self).__init__()
TypeError: __init__() takes exactly 2 arguments (1 given)

**我已经安装了所有必需的模块,但是当我想运行服务器时,显示此消息

** I have installed all necessary module installed, but when i want to runserver then show this message

推荐答案

我通过在github上使用以下软件包设法解决了相同的错误:

I managed to fix the same error by using these packages on github:

https://github.com/django-nonrel/django-nonrel
https://github.com/django-nonrel/djangotoolbox

而不是Django-Mongodb设置页面上推荐的那些.另外,请确保使用每个master分支,以免遇到兼容性问题.如果您使用的是pip,则可以分别pip install以下各行,或将其放入项目的requirements.txt文件版本中:

instead of the ones recommended on Django-Mongodb's setup page. Also, make sure to use the master branch of each, so as to not run into compatibility problems. If you're using pip, you can either pip install each of the following lines separately, or put them into your version of a requirements.txt file for your project:

git+https://github.com/django-nonrel/django-nonrel@master
git+https://github.com/django-nonrel/djangotoolbox@master
git+https://github.com/django-nonrel/mongodb-engine@master

然后运行

pip install -r requirements.txt

这篇关于Django MongoDB问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆