更新时间:2022-04-05 08:49:43
我认为 DJANGO_SETTINGS_MODULE 必须设置一些方式,所以我看在文档(链接更新)并找到:
I figured that the DJANGO_SETTINGS_MODULE had to be set some way, so I looked at the documentation (link updated) and found:
export DJANGO_SETTINGS_MODULE=mysite.settings
尽管如果您在heroku上运行服务器还不够,您还需要在其中指定。像这样:
Though that is not enough if you are running a server on heroku, you need to specify it there, too. Like this:
heroku config:set DJANGO_SETTINGS_MODULE=mysite.settings --account <your account name>
在我的具体情况下,我运行了这两个,一切都解决了:
In my specific case I ran these two and everything worked out:
export DJANGO_SETTINGS_MODULE=nirla.settings
heroku config:set DJANGO_SETTINGS_MODULE=nirla.settings --account personal
修改
我也想指出,每次关闭或重新启动虚拟环境时,都必须重新执行此操作。相反,您应该通过转到venv / bin / activate并添加行来自动执行该过程:将DJANGO_SETTINGS_MODULE = mysite.settings
设置到代码的底部。从现在开始,每次激活虚拟环境时,您都将使用该应用的设置。
I would also like to point out that you have to re-do this every time you close or restart your virtual environment. Instead, you should automate the process by going to venv/bin/activate and adding the line: set DJANGO_SETTINGS_MODULE=mysite.settings
to the bottom of the code. From now on every time you activate the virtual environment, you will be using that app's settings.