2

我在 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',
    ])

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

4

2 回答 2

1

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

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

于 2018-11-07T23:32:38.383 回答
0

备查:

在 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
于 2018-11-13T10:19:55.830 回答