简体   繁体   English

为什么 static 文件在 Heroku 上提供而不激活 WhiteNoise?

[英]Why static files are served on Heroku without activating WhiteNoise?

I followed a tutorial on deploying Django app on Heroku server and I stumble across this:我遵循了在 Heroku 服务器上部署 Django 应用程序的教程,我偶然发现了这个:

  • I have installed WhiteNoise package for serving statics我已经安装了 WhiteNoise package 来提供静态服务
  • Added inside settings.py :settings.py 中添加:
 MIDDLEWARE = [ 'whitenoise.middleware.WhiteNoiseMiddleware', ]

But omitted to activate it inside wsgi.py file:省略wsgi.py文件中激活它:

from whitenoise import WhiteNoise
from my_project import MyWSGIApp
    application = MyWSGIApp()
    application = WhiteNoise(application, root='/path/to/static/files')
    application.add_files('/path/to/more/static/files', prefix='more-files/')

Why the static files are served on the production site?为什么在生产站点上提供 static 文件? Should not the above code be responsible for this?上面的代码不应该对此负责吗?

The wsgi.py integration hasn't been required since v3.0 and was removed in v4.0.自 v3.0 起不再需要wsgi.py集成,并在 v4.0 中被删除

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM