我剛剛安裝Django管道到我的Django應用程序,它似乎並沒有壓縮我的JavaScript文件。它似乎正確安裝,因爲模板標籤正常工作。我正在使用manage.py collectstatic來壓縮文件。這是我目前的配置。我還設置了我的應用程序,以使用Django 1.3中的每個django-pipeline文檔使用django-staticfiles。Django管道不壓縮
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'site_media', 'static')
STATIC_URL = '/site_media/static/'
ADMIN_MEDIA_PREFIX = '/site_media/static/admin/'
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT, "media"),
)
STATICFILES_FINDERS = (
##Turn these on if using django.contrib.staticfiles
##'django.contrib.staticfiles.finders.FileSystemFinder',
##'django.contrib.staticfiles.finders.AppDirectoriesFinder',
##'django.contrib.staticfiles.finders.DefaultStorageFinder',
##Turn these on if using django.contrib.staticfiles
'staticfiles.finders.FileSystemFinder',
'staticfiles.finders.AppDirectoriesFinder',
'staticfiles.finders.DefaultStorageFinder'
)
PREREQ_APPS = [
# Django
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
#External
'south',
'staticfiles',
'pipeline',
]
PIPELINE_YUI_BINARY='/Applications/yuicompressor-2.4.7/build/yuicompress'
PIPELINE_JS = {
'site': {
'source_filenames': (
'js/libs/ddsmoothmenu.js',
'js/script.js',
),
'output_filename': 'js/script.min.js',
}
}
我不確定我在這裏錯過了什麼,但我確定它是某種東西。我沒有收到任何錯誤消息或任何東西,它只是不壓縮。
感謝您的幫助!
現在不應該使用'django.contrib.staticfiles',因爲它包含在標準的Django發行版中? – Cerin 2013-05-15 19:33:31
@Cerin你是對的,我剛剛解決了這個問題。我不再使用django-staticfiles,而是使用contrib。 – ralph 2013-05-17 23:29:24