2

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 setup

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

pip install git+https://github.com/django-nonrel/[email protected]

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',
)

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

python manage.py runserver

I am getting an error like this,

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.?

1
  • Are you using Python 2 or Python 3? Commented Apr 26, 2015 at 9:17

2 Answers 2

4

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

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

Perhaps you should consider using py2 for this project.

Sign up to request clarification or add additional context in comments.

2 Comments

what about mongo engine? Does that support py3?
This mongo engine(the one you used above) depends on Django-nonrel. So I don't think it supports py3, either.
0

In 2021 MongoDB supports Py3 and Django with 3 Engines. Its PyMongo, MongoEngine and Djongo.

  • PyMongo is the standard driver through which MongoDB can interact with Django.
  • MongoEngine is similar to a Object-Relational-Mapper in relational databases
  • djongo transpiles all the SQL queries to MongoDB syntax queries.

MongoDB Connection Examples

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.