繁体   English   中英

当 DEBUG=False 时,Divio Live 服务器不提供静态文件

[英]Divio Live server not serving the static files when DEBUG=False

我正在 Divio Cloud 中运行一个网站。 我的测试服务器可以很好地提供静态文件,但我的 Live 服务器给出 404。当我在 Live 服务器上将 DEBUG 切换为 True 时,它​​开始很好地提供静态文件。

当 Live 服务器启动时,它在日志中包含以下内容:

[uwsgi-static] added mapping for /static/ => /app/static_collected

这不应该照顾正确地提供静态文件吗?

--编辑--更多信息。 我实际上没有任何“正常”的静态文件。 我使用 {% static %} 添加了一个静态文件,它正在工作! 不工作的文件用 django-sass-processor 和 django-compressor 收集。 我在settings.py中有:

STATICFILES_FINDERS.extend([
    'compressor.finders.CompressorFinder',
    ])

这不应该只影响收集文件的时间吗?

我认为问题很可能是因为您使用的是 Django Compressor。 有多种不同的方式可以使用 Django Compressor。

在其文档中,请参阅离线压缩 这是它在 Divio Cloud 上工作所需要的。

备查:

在 Divio 环境中,为了让基于压缩器的处理器(在这种情况下是 django-sass-processor)工作,在 Dockerfile 的末尾添加以下几行:

 RUN DJANGO_MODE=build python manage.py compilescss

# <STATIC> 
RUN DJANGO_MODE=build python manage.py collectstatic --noinput
# </STATIC>

# Remove the css files in development environments (in Live they
# are already collected)
RUN DJANGO_MODE=build python manage.py compilescss --delete-files

暂无
暂无

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

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