11

I'm unable to run django mongo engine properly.

My database entry in settings.py is

DATABASES = {
'default': {
    'ENGINE': 'django_mongodb_engine',
    'NAME': 'local',
}
}

and my pip freeze result is

Django==1.8.2
django-mongodb-engine==0.5.2
djangotoolbox==1.6.2
pymongo==3.0.2

error while running

python manage.py runserver

is

django.core.exceptions.ImproperlyConfigured: 'django_mongodb_engine' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
u'base', u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3'
Error was: cannot import name BaseDatabaseFeatures

Any suggestions how to solve this.

5
  • Take a look at django-nonrel Commented May 29, 2015 at 10:27
  • @ajaysingh, how to solve this problem? i am facing same issue Commented Jan 30, 2018 at 6:55
  • @jignasha django-norel is not supported in latest versions of django. This library is deprecated. Commented Feb 5, 2018 at 9:53
  • @ajaysingh,so What is alternative to use mongoDB with Django? how to solve this problem? Commented Feb 5, 2018 at 10:43
  • For my specific use case, I moved to flask. Commented Feb 8, 2018 at 11:03

8 Answers 8

9

If you are using djongo and face this error when you call make migrations do this:

Open terminal and install pytz (pip install pytz)

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

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

You need django-nonrel installed as well, as per the documentation.

1 Comment

trying this : pip install git+github.com/django-nonrel/[email protected] but nothing is happening after this. Any alternatives to install django-nonrel?
2

Well, I got the same problem with my pipenv activated. Later, I figured out djongo was not installed in my pipenv. I just installed it. It's been working fine now.

pipenv install djongo

Comments

1

But, the main drawback is django-nonrel works only if you use Python2.x, it cannot work with Python3.x

1 Comment

This sounds more like a comment and not as an answer to this question. If I am wrong, please edit your answer to clearly demonstrate how this answers the question. Otherwise, please leave it as a comment once you earn enough reputation.
1

Try uninstalling 'Pymongo' and install it as 'pip install pymongo' as compared to installing it via an ide

1 Comment

Hi, how did you fix the issue "React app with Django error 'string indices must be integers'"? You seem to have deleted the question on StackOverflow.
0

I had this issue. If you plan to work with Django 1.7.x, 1.8.x, a lib that works just fine is:
django-mongoengine v0.2.1

In later versions (pip install django-mongoengine) it comes forced the install of Django 2.x (which you can still cancel by adding --no-deps) but still, less hassle if force the django-mongoengine package version by: `pip install git+https://github.com/MongoEngine/[email protected]

The requirements.txt file remains something like this:

Django==1.7.11
-e git+https://github.com/MongoEngine/django-mongoengine@4ea7168faf9b6f67a5c9e8e82690b4310aca0ff0#egg=django_mongoengine-v0.2.1
djangotoolbox==1.8.0
mongoengine==0.13.0
pymongo==2.8
pyserial==3.1.1
requests==2.13.0
six==1.10.0
wheel==0.24.0

The good of of django-mongoengine is that mongoengine easily allows you to access pymongo methods:

class Post(Document):
    #fields    

collection = Post._get_collection()
collection.update({}, {"$set": {"newfield": 1}}, multi=True)

Comments

0

This error occurs because the django utils.py file does not recognize that django is an available backend. To solve this error, please follow these steps:

  1. Go to C:\Users\User\AppData\Local\Programs\Python\Python38-32\Lib\site-packages and find the django folder.

  2. Now cut and paste the django folder in the C:\Users\User\AppData\Local\Programs\Python\Python38-32\Lib\site -packages\django\db\backends directory.

  3. Now you might be getting the error cannot import six from django.utils. For resolving that go to C:\Users\User\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\django\db\backends\django\operations.py file and replace the line from django.utils import six , datetime to from django.utils import datetime and beneath that just write import six.

  4. Now in the settings.py file of your django project add the lines

    DATABASES = {
       'default': {
        'ENGINE': 'django.db.backends.djongo',
        'NAME': 'admin',
     }
    }
    

Comments

0

Newer versions of pymongo and djongo are not compatible, This works :

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
django = "*"
django-crispy-forms = "*"
django-rest-framework = "*"
social-auth-app-django = "*"
social-auth-app-django-mongoengine = "*"
django-ses = "*"
djongo = "==1.3.6"
python-dotenv = "*"
djoser = "*"
pymongo = "==3.12.3"
pytz = "*"

[dev-packages]

[requires]
python_version = "3.11"

Comments

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.