1

Here is what I have done so far,

1) I installed Django, and started a project using:

django-admin.py startproject helloworld

2) I downloaded django non-rel, djangotoolbox and django-mongodb-engine I installed these using sudo python setup.py install

3) Added djangotoolbox to INSTALLED_APPS, and added django_mongodb_engine as database back end engine.

4) I have a sample model like this:

from django.db import models
from djangotoolbox import *

class Post(models.Model):
    title = models.CharField()
    text = models.TextField()
    tags = ListField()
    comments = ListField()

5) Started python repl using: python manage.py shell

6) And did this:

    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']
... )

I got this error, I don't know how to fix this

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

What am i doing wrong here? how do i fix it?

Nicolas Cortot
  • 6,591
  • 34
  • 44
Praveen
  • 2,400
  • 3
  • 23
  • 30

1 Answers1

0

LOOKUP_SEP was here in Django 1.4, but has been removed in 1.5, so my guess is you are using an olfer version of djangotoolbox.

You probably need to update your packages, try to follow the instructions here: http://django-mongodb-engine.readthedocs.org/en/latest/topics/setup.html

Nicolas Cortot
  • 6,591
  • 34
  • 44