how to connect Django project to mongoDB?

42 views Asked by At

i have django project where its connected to the default sqlite3 database i want to change the database to the mongoDB but its not working i am using the below packages

settings.py:

DATABASES = {
    'default': {
        'ENGINE': 'djongo',
        'NAME': '3DHologram',
        'ENFORCE_SCHEMA': False,
        'CLIENT': {
            'host': 'mongodb+srv://testdevleb:[email protected]/3DHologram?retryWrites=true&w=majority',
            'username': 'testdevleb',
            'password': 'JdcdUI7kNMB4hvfil',
            'authMechanism': 'SCRAM-SHA-1',
            'authSource': 'admin',
        }
    }
}

packages:

  • Django==4.1.13
  • djongo==1.2.3
  • dnspython==2.4.2
  • pymongo==3.10.1
  • pytz==2023.3.post1

once i try the below command

python manage.py migrate

error:

File "F:\private_projects\videoproject\myvenv\Lib\site-packages\django\db\utils.py", line 126, in load_backend raise ImproperlyConfigured( django.core.exceptions.ImproperlyConfigured: 'djongo' isn't an available database backend or couldn't be imported. Check the above exception. To use one of the built-in backends, use 'django.db.backends.XXX', where XXX is one of: 'mysql', 'oracle', 'postgresql', 'sqlite3'

0

There are 0 answers