Djoko从Heroku收集,每次都推到S3 [英] Django collectstatic from Heroku pushes to S3 everytime
问题描述
然而,在Heroku上执行相同的操作会导致每个文件被推送,不管设置是否相同。然后我查看了Heroku本身文件的修改时间,似乎是os.stat(static_filename).st_mtime与上次推送的时间一样。
$ b $这是预期的行为吗?
尝试设置 DISABLE_COLLECTSTATIC = 1
作为您的应用程序的环境设置 - 应该禁用它在每次推送时运行。
有关详细信息,请参阅此文章 - https: //devcenter.heroku.com/articles/django-assets :
>有时,你可能不希望Heroku代表你的收藏。
>您可以通过启用user-env-compile来禁用collectstatic:
$ heroku实验室:enable user-env-compile
$ heroku config:set DISABLE_COLLECTSTATIC = 1
我发现只需设置配置就可以了 - 不需要也启用 user-env-编译
- 这可能是从实验室转移到生产中?
注意部署由Heroku python buildpack管理,您可以可以在这里看到 - https://github.com/heroku/heroku-buildpack-python/
编辑1
我刚完成了一堆测试并且可以确认 DISABLE_COLLECTSTATIC
确实禁用收藏,不管 user-env-compile
设置 - 我认为现在在主干(但这是猜测)。似乎不在乎设置是什么 - 如果 DISABLE_COLLECTSTATIC
作为一个config var使用它。
I'm using django-storages for static files with S3 (and S3BotoStorage). When I do collectstatic from my local machine, the behaviour is as expected, where only modified files are pushed to S3. This process needs python-dateutils 1.5 to check for modified time.
However, doing the same on Heroku results in every file being pushed regardless, although the setup is the same. I then looked into the modified time of the files on Heroku itself, and it seems like, the os.stat(static_filename).st_mtime is the same as the time of the last push.
Is this expected behaviour? Does heroku copy around files even when there is no change from git?
Try setting DISABLE_COLLECTSTATIC=1
as an environment setting for your app - that should disable it from running on every push.
See this article for details - https://devcenter.heroku.com/articles/django-assets :
> Sometimes, you may not want Heroku to run collectstatic on your behalf.
> You can disable collectstatic by enabling user-env-compile as well:
$ heroku labs:enable user-env-compile
$ heroku config:set DISABLE_COLLECTSTATIC=1
I've found that simply setting the config will do - no need to also enable user-env-compile
- it may be that that this has passed from labs into production?
NB the deployment is managed by the Heroku python buildpack, which you can see here - https://github.com/heroku/heroku-buildpack-python/
EDIT 1
I've just done a bunch of tests on this, and can confirm that DISABLE_COLLECTSTATIC
does indeed disable collectstatic, irrespective of the user-env-compile
setting - I think that's now in the main trunk (but that's speculation). Doesn't seem to care what the setting is - if DISABLE_COLLECTSTATIC
exists as a config var it is used.
这篇关于Djoko从Heroku收集,每次都推到S3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!