为什么在不激活 WhiteNoise 的情况下在 Heroku 上提供静态文件?
Why static files are served on Heroku without activating WhiteNoise?
我遵循了有关在 Heroku 服务器上部署 Django 应用程序的教程,但我偶然发现了这个:
- 我已经安装了用于服务静态的 WhiteNoise 包
- 里面加了settings.py:
MIDDLEWARE = [
'whitenoise.middleware.WhiteNoiseMiddleware',
]
但是省略了在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/')
为什么在生产站点上提供静态文件?上面的代码不应该对此负责吗?
我遵循了有关在 Heroku 服务器上部署 Django 应用程序的教程,但我偶然发现了这个:
- 我已经安装了用于服务静态的 WhiteNoise 包
- 里面加了settings.py:
MIDDLEWARE = [ 'whitenoise.middleware.WhiteNoiseMiddleware', ]
但是省略了在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/')
为什么在生产站点上提供静态文件?上面的代码不应该对此负责吗?