Can't find img pythonanywhere django

Viewed 36

I put the project on both heroku and pythonanywhere and on both platforms there is a problem with the fact that it does not find exactly images.

Path to static at pythonanywhere

enter image description here

Staic settings in project:

STATIC_URL = '/static/'
STATIC_ROOT = 'staticfiles'

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static')
]
1 Answers

In the documentation:

The absolute path to the directory where collectstatic will collect static files for deployment.

(emphasis mine)

So yes, you need to make sure you run the management command and change your setting to have an absolute path. Why does it work on localhost? Because DEBUG ignores STATIC_ROOT.

Related