django.core.exceptions.ImproperlyConfigured: 'django_mongodb_engine' isn't an available database backend
Asked Answered
D

8

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.

Digitigrade answered 29/5, 2015 at 10:19 Comment(5)
Take a look at django-nonrelTriparted
@ajaysingh, how to solve this problem? i am facing same issueAvionics
@jignasha django-norel is not supported in latest versions of django. This library is deprecated.Digitigrade
@ajaysingh,so What is alternative to use mongoDB with Django? how to solve this problem?Avionics
For my specific use case, I moved to flask.Digitigrade
I
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)

Inandin answered 28/12, 2021 at 13:42 Comment(1)
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.Overbold
H
3

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

Herzl answered 29/5, 2015 at 10:27 Comment(1)
trying this : pip install git+github.com/django-nonrel/[email protected] but nothing is happening after this. Any alternatives to install django-nonrel?Digitigrade
P
1

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

Puggree answered 8/1, 2018 at 13:18 Comment(1)
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.Devastate
M
1

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

Mothy answered 14/4, 2020 at 12:12 Comment(1)
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.Parisparish
F
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
Fernyak answered 2/1, 2022 at 16:37 Comment(0)
M
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)
Meaty answered 21/3, 2018 at 22:30 Comment(0)
G
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',
     }
    }
    
Gaming answered 6/1, 2020 at 10:40 Comment(0)
H
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"
Hemeralopia answered 7/1 at 7:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.