Collectstatic error while deploying Django app to Heroku

前端 未结 10 1941
长情又很酷
长情又很酷 2020-12-04 06:34

I\'m trying to deploy a Django app to Heroku, it starts to build, download and installs everything, but that\'s what I get when it comes to collecting static files



        
10条回答
  •  孤街浪徒
    2020-12-04 07:12

    Heroku had made a document with suggestions on how to handle this https://devcenter.heroku.com/articles/django-assets

    add to settings.py

    BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
    STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
    STATIC_URL = '/static/'
    STATICFILES_DIRS = (
        os.path.join(BASE_DIR, 'static'),
    )
    

    make a directory in the root of your project called staticfiles, put a favicon or something in there, just make sure git tracks it. Then the collectstatic command should finish on heroku.

提交回复
热议问题