这是我到目前为止所做的,
1)我安装了 Django,并使用以下方法启动了一个项目:
django-admin.py startproject helloworld
2) 我下载了 django non-rel、djangotoolbox 和 django-mongodb-engine 我安装了这些使用
sudo python setup.py install
3) 将 djangotoolbox 添加到 INSTALLED_APPS,并添加 django_mongodb_engine 作为数据库后端引擎。
4)我有一个这样的示例模型:
from django.db import models
from djangotoolbox import *
class Post(models.Model):
title = models.CharField()
text = models.TextField()
tags = ListField()
comments = ListField()
5) 使用以下命令启动 python repl:python manage.py shell
6)这样做:
from hello.models import Post
post = Post.objects.create(
... title='Hello MongoDB!',
... text='Just wanted to drop a note from Django. Cya!',
... tags=['mongodb', 'django']
... )
我收到此错误,我不知道如何解决此问题
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/django/db/models/manager.py", line 149, in create
return self.get_query_set().create(**kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 416, in create
obj.save(force_insert=True, using=self.db)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/base.py", line 546, in save
force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/base.py", line 650, in save_base
result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/manager.py", line 215, in _insert
return insert_query(self.model, objs, fields, **kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 1675, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/query.py", line 237, in get_compiler
return connection.ops.compiler(self.compiler)(self, connection, using)
File "/usr/local/lib/python2.6/dist-packages/django/db/backends/__init__.py", line 703, in compiler
self._cache = import_module(self.compiler_module)
File "/usr/local/lib/python2.6/dist-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/home/Desktop/helloworld/django_mongodb_engine/compiler.py", line 18, in <module>
from djangotoolbox.db.basecompiler import (
File "/usr/local/lib/python2.6/dist-packages/djangotoolbox-1.4.0-py2.6.egg/djangotoolbox/db/basecompiler.py", line 9, in <module>
from django.db.models.sql.constants import LOOKUP_SEP, MULTI, SINGLE
ImportError: cannot import name LOOKUP_SEP
我在这里做错了什么?我如何解决它?