【发布时间】:2012-10-12 21:37:02
【问题描述】:
我有一个 Dreamhost 共享服务器,用于托管 Passenger Python/Django。目前我有一个收集非 python 文件的全局文件夹(/public/static、/public/media)。当我“收集静态”时,我的所有应用程序的 */static 文件都会被复制到全局 /public/static 文件夹中。到目前为止还不错。
1) 我已经厌倦了使用 collectstatic。我想删除我的应用程序的 */static 文件夹并将它们的文件放在全局 /public/static 中。这适用于 Dreamhost,因为 Passenger Python 将 Apache 的文档根指向 /public,它将正确检索 /public/static 和 /public/media。但是在开发方面我没有这样的功能(在 python manage.py 下)。
2) Dreamhost/共享主机下的静态/缓存文件有什么优化?
以下是我的设置:
网站设置:
STATICFILES_DIRS = (
ABS_PATH + '/???/???/static/', #My App's static dir
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder'
)
TEMPLATE_DIRS = (
#ABS_PATH + '/hdrtoronto/hdrtoronto/templates/'
ABS_PATH + '/templates/'
)
网址.py:
if os.environ.get("django_dev", None):
urlpatterns += static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT)
urlpatterns += static(settings.STATIC_URL, document_root = settings.STATIC_ROOT)
【问题讨论】: