我正在使用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