我想将我在 Atlas(Mlab) 上的数据库与我的 django 项目连接起来。我已经成功安装了 python 3.7、django、djongo。我面临一个错误:
django.core.exceptions.ImproperlyConfigured: 'djongo' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'postgresql', 'sqlite3'
我正在分享我的 settings.py(数据库部分)文件供您参考:
DATABASES = {
'default': {
'ENGINE': 'djongo',
'NAME': 'ReminderSystemDbTest',
'HOST': 'mongodb+srv://jigarjoshiuser:joshipinakin@cluster0.mhzxu.gcp.mongodb.net/ReminderSystemDbTest?retryWrites=true&w=majority',
'USER': 'jigarjoshiuser',
'PASSWORD': 'joshipinakin',
}
#mongodb+srv://jigarjoshiuser:joshipinakin@databaseconnectivtiy.mhzxu.gcp.mongodb.net/ReminderSystemDbTest?retryWrites=true&w=majority
}
}
我正在分享我的 manage.py 文件以供参考:
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'db_connectivity.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
我的wsgi文件是:
import os
from django.core.wsgi import get_wsgi_application
import sys
sys.path.append("F:/connecting_database/db_connectivity")
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'db_connectivity.settings')
application = get_wsgi_application()
层次结构是:
CONNECTING_DATABASE->
db_connectivity
db_connectivity
pycache
__init.py
settings.py
urls.py
wsgi.py
db.sqlite3
manage.py