10

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.

randomuser
  • 1,201
  • 2
  • 10
  • 19

7 Answers7

7

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

Open terminal and install pytz (pip install pytz)

  • 2
    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](/help/how-to-answer). – Community Dec 28 '21 at 14:38
3

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

SaeX
  • 17,240
  • 16
  • 77
  • 97
  • 5
    trying this : pip install git+https://github.com/django-nonrel/django@nonrel-1.5 but nothing is happening after this. Any alternatives to install django-nonrel? – randomuser May 29 '15 at 12:26
1

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

  • 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. – Yannis Jan 08 '18 at 13:41
1

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

Piyush Singh
  • 533
  • 5
  • 17
  • 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. – Octocat Apr 20 '20 at 14:42
1

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
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/django-mongoengine@v0.2.1

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)
Evhz
  • 8,852
  • 9
  • 51
  • 69
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',
     }
    }
    
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
Aman Sutariya
  • 11
  • 1
  • 2