django-pipeline DEBUG=True, compressed file not found

牧云@^-^@ 提交于 2019-12-24 00:29:31

问题


OK. I going mad using django-pipeline and I am one step away from not using it at all. I am not in production yet. All of the below is happening in development (DEBUG=True) mode. My css static files live in a dir called 'project/static/css' and I collect them in a dir called 'project/static_remote/css' (inside my own development server).

I have set the following:

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',
    },
}

When I run collectstatic everything goes well and all the files in the master branch (plus the compressed one, master.css) are copied successfully into the 'project/static_remote/css'. Until here hoorey!

BUT, when i runserver then my compressed file is not found by the {% static 'master' %}(href='/static/css/master.css') inside my template (obviously i have {% load pipeline %}). Same thing applies if i run findstatic 'css/master.css'. Why is this happening? All the other files (fonts.css animate.css etc) are found by findstatic.

I suspect this is because there is no copy of master.css inside 'project/static/css'. Or is this happening because I have DEBUG = True?

If I manually copy 'master.css' from 'project/static_remote/css' to 'project/static/css' then everything works fine, but I do not want that. Any suggestions please?


回答1:


When DEBUG = True

PIPELINE_ENABLED = False



来源:https://stackoverflow.com/questions/33543890/django-pipeline-debug-true-compressed-file-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!