简体   繁体   中英

django-pipeline DEBUG=True, compressed file not found

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?

When DEBUG = True

PIPELINE_ENABLED = False

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM