I am running Django 1.8.2 and I am using django-pipeline 1.5.1 to collect and compress my CSS and JS files.
After running python manage.py collectstatic
, Django collects all files and compresses them as configured. But when I want to access the webserver, the dev-server does not serve all staticfiles. Namely the ones from django-pipeline cannot be loaded.
My template looks like this:
{% load pipeline %}
...
{% javascript 'master' %}
When the page is loaded in the dev-server, Django translate the code to:
<script charset="utf-8" src="/static/compressed/master.js" type="text/javascript"></script>
<link href="/static/img/favicon.ico" rel="icon"></link>
That's pretty good so far. But the files from pipeline cannot be served:
"GET /static/compressed/master.js HTTP/1.1" 404 1774
But I can see the failing master.js
in my static-folder:
static
├── compressed
│ └── master.js
│ └── ...
└── img
└── favicon.ico
Why is the favicon served, but the compressed files are not? I followed the official tutorial and double checked it. Thanks for you help.
Addition The site works well, staticfiles are normally served. The problem does only occur with the compressed files from django-pipeline.
Relevant settings
DEBUG = True
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
# 3rd party
'pipeline',
'filer',
'mptt',
'easy_thumbnails',
'tinymce',
# Own apps
'polls',
'pages',
'login',
'archive',
)
MIDDLEWARE_CLASSES = (
'pipeline.middleware.MinifyHTMLMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
[...]
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
# Define Paths for Pipeline
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'pipeline.finders.PipelineFinder',
)
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'templates/dpb'),
)
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'
### Pipeline ###
# Set Pipeline Compilers
PIPELINE_COMPILERS = (
'pipeline.compilers.sass.SASSCompiler',
)
PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'
PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'
PIPELINE_ENABLED = True
PIPELINE_CSS = {
'master': {
'source_filenames': (
'css/*.sass',
),
'output_filename': 'compressed/master.css',
'extra_context': {
'media': 'screen, projection',
},
},
'vendor': {
'source_filenames': (
'assets/bootstrap/css/bootstrap.min.css',
'assets/bootstrap/css/bootstrap-theme.min.css',
'assets/bootswatch/bootswatch.min.css',
),
'output_filename': 'compressed/vendor.css'
}
}
PIPELINE_JS = {
'master': {
'source_filenames': (
'js/*.js',
),
'output_filename': 'compressed/master.js'
},
'vendor': {
'source_filenames': (
'assets/jquery/jquery.min.js',
'assets/bootstrap/js/bootstrap.min.js',
),
'output_filename': 'compressed/vendor.js'
}
}
### END Pipeline ###
[...]
urls.py
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)