我正在尝试将 heroku 上托管的 djnago 应用程序连接到 mongodb atlas。我还将 heroku 设置上的 DATABASE_URL 更改为:mongodb+srv://<name>:<password>@cluster0.wtnph.mongodb.net/test我正在使用 python 3.9 和 django 3.0.5 但是当部署到 heroku 时,我收到错误。> -----> Python app detected-----> No change in requirements detected, installing from cache-----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2-----> Installing SQLite3-----> Installing requirements with pip-----> $ python manage.py collectstatic --noinput Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 345, in execute settings.INSTALLED_APPS File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 76, in __getattr__ self._setup(name) File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 63, in _setup self._wrapped = Settings(settings_module) File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 142, in __init__ mod = importlib.import_module(self.SETTINGS_MODULE) File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level)我什至尝试从 Settings.py 中删除 DATABASE 字典
1 回答
沧海一幻觉
TA贡献1824条经验 获得超5个赞
我能够通过更改 settings.py 中的这一行来解决该问题
从:
# Activate Django-Heroku.
django_heroku.settings(locals()),
到:
# Activate Django-Heroku.
django_heroku.settings(locals(), databases=False),
添加回答
举报
0/150
提交
取消