我想在個人應用上使用heroku上的django-pipeline和django-storage。只使用Django管道完美工作,只使用django存儲工程就像一個魅力,但我不能讓他們兩個一起工作:(如何讓django-storage和django-pipeline一起工作
當你閱讀文檔,你會發現這使得兩個工作collecstatic:
Django的管道:
settings.py
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
PIPELINE_CSS = {
'app': {
'source_filenames': (
'css/*',
),
'output_filename': 'css/min.css',
'variant': 'datauri',
},
}
Django的存儲
settings.py
STATICFILES_STORAGE = 's3storages.StaticStorage'
s3storages.py
from storages.backends.s3boto import S3BotoStorage
StaticStorage = lambda: S3BotoStorage(
bucket='app_name',
location='assets'
)
所以這兩個應用程序都需要設置STATICFILE_STORAGE;當我爲亞馬遜s3設置存儲空間時; Django的管道不創建min.css和min.js ...
所以,我發現this solution on stack,也做了以下內容:
from staticfiles.storage import CachedFilesMixin
from pipeline.storage import PipelineMixin
from storages.backends.s3boto import S3BotoStorage
class S3PipelineStorage(PipelineMixin, CachedFilesMixin, S3BotoStorage):
pass
# Define bucket and folder for static files.
StaticStorage = lambda: S3BotoStorage(
bucket='app_name',
location='assets'
)
現在,每次使用collectstatic命令時,靜態文件被髮送亞馬遜S3但django管道min.css和min.js不發送...我的STATIC_ROOT目錄中也沒有跟蹤...
你知道我怎麼可以一起使用嗎?
編輯1:
現在我有這樣的:(我改變s3storage :))
settings.py
STATICFILES_STORAGE = 's3storages.StaticStorage'
s3storage.py
from staticfiles.storage import CachedFilesMixin
from pipeline.storage import PipelineMixin
from storages.backends.s3boto import S3BotoStorage
class S3PipelineStorage(PipelineMixin, CachedFilesMixin, S3BotoStorage):
pass
# Define bucket and folder for static files.
StaticStorage = lambda: S3PipelineStorage(
bucket='app_name',
location='assets'
)
我會fork django-pipeline並添加PIPELINE_STATICFILES_STORAGE的選項,併發送一個拉請求來解釋對特定選項的需求。 – demux 2013-05-10 10:57:59
您是否已將STATICFILES_STORAGE設置爲指向S3PipelineStorage? – cyberdelia 2013-05-10 14:59:16
Oups我編輯了我的問題來回答你。 – 2013-05-10 17:57:05