我正在使用heroku來託管我的Django(1.6)應用程序(稱爲'Zen')。問題是靜態文件沒有顯示。換句話說,在我的應用程序中沒有CSS和JS,因爲它沒有找到這些文件。我看着其他問題在這裏,我配置如下我的應用程序:靜態文件狀態'404
Settings.py:
##### Static asset configuration #####
STATIC_ROOT = 'staticfiles'
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
urls.py:
from django.conf.urls.static import static
from zen import settings
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL,
document_root=settings.STATIC_ROOT)
urlpatterns += patterns('',
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
)
wsgi.py:
import os
from django.core.wsgi import get_wsgi_application
from dj_static import Cling
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "zen.settings")
application = Cling(get_wsgi_application())
顯然,推我的應用程序git push heroku master
畢竟是偉大的工作:
-----> Preparing static assets Running collectstatic... 69 static files copied to '/app/staticfiles'.
但你可以看到有我的應用程序(http://obscure-reef-8874.herokuapp.com/)沒有CSS。我看着我的應用程序的日誌,主要是CSS和JS文件處於404狀態......我嘗試了一切,你能幫助我嗎?
編輯:
我沒有發現這個錯誤,我重新創建一個應用程序,它的工作,簡單。
嘗試'STATIC_ROOT = os.path.join(PROJECT_PATH,'staticfiles')' – Leistungsabfall 2014-08-28 22:46:29
它不起作用。 – rrrub 2014-08-28 23:48:37