Heroku build django应用程序不';如果DEBUG=False,则不创建静态根目录。为什么,里面是什么?

Heroku build django应用程序不';如果DEBUG=False,则不创建静态根目录。为什么,里面是什么?,django,heroku,build,django-staticfiles,Django,Heroku,Build,Django Staticfiles,heroku上的Dajango(+channels/postgres/redis)应用程序,DEBUG=True,运行良好,无错误,无异常。如果DEBUG=False,那么它实际上根本不起作用,error500。有没有线索说明调试标志是如何以这种方式参与的?多谢各位 Heroku日志示例,DEBUG=True(正常工作): 获取路径=“/” “GET/HTTP/1.1”302 “GET/accounts/login/?next=/HTTP/1.1”200 显示登录页面,确定 现在的问题是:唯一的

heroku上的Dajango(+channels/postgres/redis)应用程序,DEBUG=True,运行良好,无错误,无异常。如果DEBUG=False,那么它实际上根本不起作用,error500。有没有线索说明调试标志是如何以这种方式参与的?多谢各位

Heroku日志示例,DEBUG=True(正常工作):

获取路径=“/”

“GET/HTTP/1.1”302

“GET/accounts/login/?next=/HTTP/1.1”200

显示登录页面,确定

现在的问题是:唯一的区别是DEBUG=False:

获取路径=“/”

用户警告:在:/app/pickupteaming/staticfiles处没有目录/

“GET/HTTP/1.1”302

“GET/accounts/login/?next=/HTTP/1.1”500

Heroku日志示例详述如下:

2020-07-23T16:17:32.649059+00:00 heroku[router]: at=info method=GET path="/" host=immense-escarpment-72885.herokuapp.com request_id=22b8a783-04e8-4fda-a185-f0f39c69125e fwd="68.14.159.220" dyno=web.1 connect=0ms service=125ms status=302 bytes=240 protocol=https
2020-07-23T16:17:32.527579+00:00 app[web.1]: /app/.heroku/python/lib/python3.7/site-packages/whitenoise/base.py:116: UserWarning: No directory at: /app/pickupteaming/staticfiles/
2020-07-23T16:17:32.527606+00:00 app[web.1]: warnings.warn(u"No directory at: {}".format(root))
2020-07-23T16:17:32.643881+00:00 app[web.1]: 68.14.159.220:0 - "GET / HTTP/1.1" 302
2020-07-23T16:17:32.733941+00:00 app[web.1]: 68.14.159.220:0 - "GET /accounts/login/?next=/ HTTP/1.1" 500
2020-07-23T16:17:32.739475+00:00 heroku[router]: at=info method=GET path="/accounts/login/?next=/" host=immense-escarpment-72885.herokuapp.com request_id=991497fb-57f9-42f6-ae6b-c4a85dcdc79c fwd="68.14.159.220" dyno=web.1 connect=0ms service=60ms status=500 bytes=353 protocol=https

当您将DEBUG=FALSE设置为生产模式时,Django将不会像在开发模式中那样为静态文件提供服务,因为它效率低下且不安全。您需要安装WhiteNoise并对setting.py文件进行一些调整。通过以下方式查看此优秀指南:

2020-07-23T16:17:32.649059+00:00 heroku[router]: at=info method=GET path="/" host=immense-escarpment-72885.herokuapp.com request_id=22b8a783-04e8-4fda-a185-f0f39c69125e fwd="68.14.159.220" dyno=web.1 connect=0ms service=125ms status=302 bytes=240 protocol=https
2020-07-23T16:17:32.527579+00:00 app[web.1]: /app/.heroku/python/lib/python3.7/site-packages/whitenoise/base.py:116: UserWarning: No directory at: /app/pickupteaming/staticfiles/
2020-07-23T16:17:32.527606+00:00 app[web.1]: warnings.warn(u"No directory at: {}".format(root))
2020-07-23T16:17:32.643881+00:00 app[web.1]: 68.14.159.220:0 - "GET / HTTP/1.1" 302
2020-07-23T16:17:32.733941+00:00 app[web.1]: 68.14.159.220:0 - "GET /accounts/login/?next=/ HTTP/1.1" 500
2020-07-23T16:17:32.739475+00:00 heroku[router]: at=info method=GET path="/accounts/login/?next=/" host=immense-escarpment-72885.herokuapp.com request_id=991497fb-57f9-42f6-ae6b-c4a85dcdc79c fwd="68.14.159.220" dyno=web.1 connect=0ms service=60ms status=500 bytes=353 protocol=https