Django collectstatic from Heroku pushes to S3 everytime

前端 未结 6 1349
忘了有多久
忘了有多久 2021-02-02 01:23

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 a

6条回答
  •  悲哀的现实
    2021-02-02 01:56

    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.

提交回复
热议问题