Search code examples
cssdjangoherokudeploymentstatic-files

My CSS and JS files won't apply to deployment


I've tried - https://devcenter.heroku.com/articles/django-assets and it won't work.

The logs tell me this:

post-processed (other static files)

post-processed 'app.js'

post-processed 'style.css'

63 static files copied to /app/staticfiles, 63 post-processed

verifying deploy... done.

Then when I run heroku open, the app still looks all bare bones. Help would be greatly appreciated! Here is the stuff in settings.py

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


Solution

  • I needed to point a url in urls.py at the STATIC_ROOT.

    STATIC_ROOT should be the same as STATICFILES_DIRS. eg.

    STATIC_ROOT = 'static_assets'
    STATICFILES_DIRS = (
        os.path.join(PROJECT_ROOT, 'static_assets'),
    )
    

    STATIC_URL on the other hand is where Heroku puts static files after calling collectstatic.