2015-11-05 43 views
2

OK。我使用django-pipeline發瘋,而且我完全沒有使用過它。 我還沒有生產。以下所有情況正在開發中(DEBUG=True)模式。我的css靜態文件存在於一個名爲'project/static/css'的目錄中,我將它們收集到名爲'project/static_remote/css'的目錄中(在我自己的開發服務器中)。django-pipeline DEBUG = True,找不到壓縮文件

我已經設置了以下內容:

import os 
from os.path import abspath, dirname, join 

# PATH CONFIGURATION 
here = lambda *x: join(abspath(dirname(__file__)), *x) 
PROJECT_ROOT = here("..", "..") 
root = lambda *x: join(abspath(PROJECT_ROOT), *x) 

# STATIC FILES CONFIGURATION 
STATIC_ROOT = root('static_remote') 
STATIC_URL = '/static/' 
STATICFILES_DIRS = (root('static'),) 
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder', 
    'django.contrib.staticfiles.finders.AppDirectoriesFinder', 
    'pipeline.finders.PipelineFinder', 
) 
STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage' 

# PIPELINE CONFIGURATION 
PIPELINE_ENABLED = True 
PIPELINE_CSS = { 
    'master': { 
     'source_filenames': (
      'css/fonts.css', 
      'css/animate.css', 
      'css/style.css', 
      'css/responsive.css', 
     ), 
     'output_filename': 'css/master.css', 
    }, 
} 

當我運行collectstatic一切順利,並在master分支中的所有文件(加上壓縮之一,master.css)被成功地複製到「項目/ static_remote/CSS'。在這裏hoorey!

但是,當我runserver然後我的壓縮文件不被{% static 'master' %}href='/static/css/master.css')我的模板中發現(很明顯,我有{% load pipeline %})。如果我運行findstatic 'css/master.css',則同樣適用。這是爲什麼發生? 所有其他文件(fonts.css animate.css etc)均由findstatic找到。

我懷疑這是因爲'project/static/css'裏沒有master.css的副本。或者是因爲我有DEBUG = True

如果我從'project/static_remote/css'手動複製'master.css'到'project/static/css',那麼一切正常,但我不想這樣。有什麼建議嗎?

回答

0

當DEBUG =真

PIPELINE_ENABLED = False

+0

請給予更詳細的答案。只是一個鏈接到文檔是沒有那麼有用,因爲它可能是。 –

+0

事實上,當你在開發中('DEBUG = True'),你應該設置'PIPELINE_ENABLED = False'。一旦進入生產,只需設置DEBUG = False和PIPELINE_ENABLED = True,管道將處理剩下的事情! –