Django on Heroku - no static files found

I am running Django on Heroku. I can successfully run collectstatic, but when I go to the site, it is obvious that Django cannot find my static files. Here is a snippet from my settings - I think this is basically standard stuff:

STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'

PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))


# Additional locations of static files
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(PROJECT_DIR, 'static'),
)

# List of finder classes that know how to find static files in
# various locations.
if CLAYS_ENV == 'dev':
    STATICFILES_FINDERS = (
        'django.contrib.staticfiles.finders.FileSystemFinder',
        'django.contrib.staticfiles.finders.AppDirectoriesFinder',
        'django.contrib.staticfiles.finders.DefaultStorageFinder',
    )

And in my case, the variable CLAYS_ENV will be set to 'dev'. Any ideas on why Django can run collectstatic successfully but can't find the files after that?

+5
source share
2 answers

CDN (, Amazon S3) Heroku. , Heroku, , , , . , CDN , Heroku "ephimeral": , , Cedar , . , Git -tracked, , .

+3

- . Collectstatic STATIC_DIRS

- , collectstatic. Ive heroku , URL- ?

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

? , , django. apache Alias

+4

All Articles