当我在本地运行 foreman start 时 - 我没有从静态加载admin css ...
但当它推动遥控它的所有工作按预期! DOH。
我希望我当地的工头模仿我的远程实例......
继承我当前的settings.py for static stuffs :(有人可以帮忙吗?)
STATIC_ROOT = ''
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static'
# Additional locations of static files
STATICFILES_DIRS = (
os.path.join(PROJECT_DIR, 'static'),
# 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.
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
答案 0 :(得分:6)
尝试修改STATIC_ROOT以说project_path / static /并运行
python manage.py collectstatic
Heroku自动运行collectstatic(如果一切设置正确):)
希望有所帮助!
答案 1 :(得分:1)
在Django文档中阅读有关静态文件的Serving Static Files in Development。它展示了如何使用你的python应用服务器使Django提供静态文件。
答案 2 :(得分:1)
在项目中添加 settings.py :
STATIC_ROOT = 'staticfiles'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
然后在项目中添加 wsgi.py :
from dj_static import Cling
application = Cling(get_wsgi_application())
答案 3 :(得分:0)
首先,@ Evgeny回答是正确答案。链接后面会给你答案。但是,我最初错过了他的答案,因为他没有内联相关部分。所以,我只想在这里内联一个选项(解决方案略有不同 - 一石二鸟):
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns = [
url(r'^admin/', admin.site.urls),
# your other urls
]
urlpatterns += staticfiles_urlpatterns()