我在 Heroku 上运行 Django。我可以成功运行 collectstatic,但是当我访问该站点时,很明显 Django 无法找到我的静态文件。这是我的设置中的一个片段——我认为这主要是标准的东西:
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',
)
在我的情况下,CLAYS_ENV 变量将设置为“dev”。关于为什么 Django 可以成功运行 collectstatic,但之后找不到文件的任何想法?