2015-11-05 45 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,管道将处理剩下的事情! –