【发布时间】:2022-01-09 10:17:23
【问题描述】:
尝试为公共 url 设置 Django 配置。
所以我先运行了这个。
$ echo "web: python manage.py runserver 0.0.0.0:\$PORT" > Procfile
$ git add Procfile
$ git commit -m "Specify the command to run your project"
在 Procfile 中:
web: python manage.py runserver 0.0.0.0:\$PORT
release: python manage.py migrate
在 Settings.py 中:
PORT = os.getenv("PORT", default="5000")
# SECURITY WARNING: don't run with debug turned on in production!
# DEBUG = True
DEBUG = os.environ.get('DJANGO_DEBUG', '') != 'False'
ALLOWED_HOSTS = ["url"]
在环境中:
PORT=5000
SECRET_KEY=value
正在使用上述命令并得到了
(portfolio) PS C:\Users\arund\Desktop\Code\Django\portfolio-project> heroku config:get PORT
5000
(portfolio) PS C:\Users\arund\Desktop\Code\Django\portfolio-project> heroku local
[OKAY] Loaded ENV .env File as KEY=VALUE Format
3:08:10 PM web.1 | CommandError: "0.0.0.0:\$PORT" is not a valid port number or address:port pair.
[DONE] Killing all processes with signal SIGINT
3:08:10 PM web.1 Exited with exit code null
我还使用了不带反斜杠和 $ 的 $PORT。我将如何从这里着手使公共 url 工作。
CommandError: "0.0.0.0:PORT" is not a valid port number or address:port pair does the same thing.
web: python manage.py runserver 0.0.0.0:5000 将适用于本地
【问题讨论】: