问题
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
回答1:
You should downgrade Django version to 2.2.8 and reinstall the project.
回答2:
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
)
来源:https://stackoverflow.com/questions/59451423/connect-mongodb-with-djongo-django