I’ve deployed my app on heroku (cedar stack) and all worked fine until a few days ago, When i noticed that my static files are not being served (appear with code ‘canceled’). Next thing i noticed is that my project suddenly had new folders on same level as manage.py : admin/, css/, img/ and js/. I didnt create admin at all, using a buildin django admin site and didnt modify it in any way. I did create css, img and js folders under static/ inside my project, and its still there along with all its content. It’s like all the folders in static/ got copied to manage.py level.
Running heroku run ls -l shows same changes on heroku. I suspect those changes cause troubles in serving static files.
heroku run python manage.py collectstatic --noinput
shows all files copied no problem.
my static dirs settings:
STATIC_ROOT = ''
STATIC_URL = '/static/'
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.join(os.path.dirname(__file__), 'static'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
I dont use S3 yet.
How to remove those files? What caused those dirs to appear?
When a Django application is deployed to Heroku,
collectstaticis automatically run (Heroku docs). This collects all the static assets from your installed apps (includingdjango.contrib.admin) and copies them to theSTATIC_ROOT.Check your
STATIC_ROOTsetting. It is probably not set correctly.Here is a tutorial on using S3 with your static files.