设置MongoDB + Django [英] Setting up MongoDB + Django

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

问题描述

我是Mongo DB和Django的新手.我一直在尝试使用Mongo DB作为Django的主要数据库.我已经按照以下链接安装了MongoDB和Django-nonrel:

I am new to Mongo DB and Django. I've been trying to use Mongo DB as my primary Database for Django. I've installed MongoDB and Django-nonrel as per the following link:

Django-MongoDB设置

我正在使用的django-nonrel版本是1.7.克隆到它的链接:

The version of django-nonrel, i am using is 1.7. Clone link to it:

pip安装git + https://github.com/django-nonrel/django@nonrel-1.7

完成所有步骤后,django项目文件中的settings.py看起来像这样:

After following all steps, my settings.py in the django project file looks something like this:

DATABASES = {
    'default': {
        'ENGINE': 'django_mongodb_engine',
        'NAME': 'blink',
        'USER': '',
        'PASSWORD': '',
        'HOST': '127.0.0.1',
        'PORT': 1234,
    }
}

INSTALLED_APPS = (
    'djangotoolbox',
)

但是在使用以下命令运行manage.py时:

But while running the manage.py using the following command:

python manage.py runserver

我遇到这样的错误,

System check identified no issues (0 silenced).
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x104a95f80>
    Traceback (most recent call last):
      File "/Users/sunilkumar/blink/lib/python3.3/site-packages/django/utils/autoreload.py", line 222, in wrapper
        fn(*args, **kwargs)
      File "/Users/sunilkumar/blink/lib/python3.3/site-packages/django/core/management/commands/runserver.py", line 107, in inner_run
        self.check_migrations()
      File "/Users/sunilkumar/blink/lib/python3.3/site-packages/django/core/management/commands/runserver.py", line 159, in check_migrations
        executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
      File "/Users/sunilkumar/blink/lib/python3.3/site-packages/django/db/utils.py", line 242, in __getitem__
        backend = load_backend(db['ENGINE'])
      File "/Users/sunilkumar/blink/lib/python3.3/site-packages/django/db/utils.py", line 108, in load_backend
        return import_module('%s.base' % backend_name)
      File "/Users/sunilkumar/blink/lib/python3.3/importlib/__init__.py", line 90, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1584, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1565, in _find_and_load
      File "<frozen importlib._bootstrap>", line 1532, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
      File "<frozen importlib._bootstrap>", line 1022, in load_module
      File "<frozen importlib._bootstrap>", line 1003, in load_module
      File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
      File "<frozen importlib._bootstrap>", line 853, in _load_module
      File "<frozen importlib._bootstrap>", line 980, in get_code
      File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
      File "/Users/sunilkumar/blink/lib/python3.3/site-packages/django_mongodb_engine/base.py", line 265
        raise ImproperlyConfigured, exc_info[1], exc_info[2]
                                  ^
    SyntaxError: invalid syntax

我无法理解该错误是什么.有人可以帮忙吗?

I am not able to understand what the error is. Can somebody please help.?

推荐答案

似乎您正在使用Python3.但是 django-mongodb-engine ,在其上的 django-nonrel 取决于,甚至还不支持Python 3.

It seems that you are using Python 3. But django-mongodb-engine, on which django-nonrel depends, doesn't even support Python 3 yet.

上面的语法错误实际上在py3中有效,但在py2中无效.因此错误.

The syntax error above is actually valid in py3, but not in py2. Thus the error.

也许您应该考虑在该项目中使用py2.

Perhaps you should consider using py2 for this project.

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

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