[Answered ]-Heroku django – messed up project structure

1👍

When a Django application is deployed to Heroku, collectstatic is automatically run (Heroku docs). This collects all the static assets from your installed apps (including django.contrib.admin) and copies them to the STATIC_ROOT.

Check your STATIC_ROOT setting. It is probably not set correctly.

Here is a tutorial on using S3 with your static files.

👤Ohad

1👍

Based on this post i learned that all this mess was caused by changing DEBUG to FALSE. Following Ohads’ advice i checked my STATIC_ROOT setting, and as you can see, it wasn’t set. Those are my fixed settings:

SETTINGS_PATH = os.path.abspath(os.path.dirname(__file__))
STATIC_ROOT = os.path.abspath(SETTINGS_PATH+'/static/')
STATIC_URL = '/static/'
STATICFILES_DIRS = ()
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

Adding:

if not settings.DEBUG:
    urlpatterns += patterns('',
        (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
    )

in myapp/urls.py solved my problem.

👤Neara

Leave a comment