0

i try connect to mongodb with djongo after reading githup page of djongo and this find same question here but no answer as well change setting.py like this

DATABASES = {
    'default': {
        'ENGINE': 'djongo',
        'NAME': 'namename',
    }
} 

after run python manage.py makemigrate i get this error:

djongo' isn't an available database backend try using "django.db.backend.XXX" where XXX is one of : "mysql" , "oracle" , "postgresql" , "sqlite3"

mongodb version = 3.4

python version = 3.6.3

djogo == 1.2.38

Nozar Safari
  • 505
  • 4
  • 17

6 Answers6

2

You should downgrade Django version to 2.2.8 and reinstall the project.

Peyman Mehrabani
  • 619
  • 6
  • 17
1

You can use mongoengine to connect django with mongodb and add above line in your settings.py file.

import mongoengine
import pymongo

HOST = 'localhost:27017'

mongoengine.connect(
    db='dbname',
    host=HOST,
    read_preference=pymongo.ReadPreference.PRIMARY_PREFERRED
)
Cerberus
  • 8,879
  • 1
  • 25
  • 40
Vaibhav Mishra
  • 227
  • 2
  • 11
1

2022: It seems djongo doesn't work with the latest versions (4.X) of django and pymongo, because I solved the issue with:

django==3.2.14
pymongo[srv]==3.12.3
Marcel
  • 2,810
  • 2
  • 26
  • 46
1

python version also matters: for me python 3.8.14 works. Tested with the following dependencies.

Python==3.8.14
Django==3.2.15
djongo==1.3.6
Mongo==3.6
pymongo==3.12.3

I think latest version of djongo with Django 3.x.x works perfect but pymongo, Mongo, and Python must be kept same.

K14
  • 181
  • 7
0

First install djongo

pip install djongo

then next makemigration and migrate

Vijay
  • 275
  • 2
  • 11
0

i install djongo it works for me with latest version of django my django version is 3.2.7 mython version is 3.8 pip install djongo will install the latest version, in my case the command installed of djongo 1.3.6 by default

and change the DB in settings.py

DATABASES = {
      'default': {
        'ENGINE': 'djongo',
        'NAME': 'db_name',
       }
    }
azhar
  • 351
  • 3
  • 13