django-pipeline DEBUG=True, compressed file not fo

2019-07-11 02:23发布

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条回答
干净又极端
2楼-- · 2019-07-11 02:38
登录 后发表回答