I am trying django-pipeline in order to minify static resources, use cache for them and make my templates simpler. My CSS and JS files are found and loaded by my browser but it takes about 10 seconds for my (very simple) home page to load.
I am using Python 2.7.6, Django 1.7.3 and django-pipeline 1.4.3. PyCharm runs the development server with a local virtualenv.
My settings.py contains the following:
DEBUG = True
TEMPLATE_DEBUG = DEBUG
INSTALLED_APPS = (
'django_admin_bootstrapped', # custom admin
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# pip installed apps
'pipeline',
# project apps
'myapp',
)
MIDDLEWARE_CLASSES = (
'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',
'pipeline.middleware.MinifyHTMLMiddleware',
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'pipeline.finders.FileSystemFinder',
'pipeline.finders.CachedFileFinder',
'pipeline.finders.PipelineFinder',
)
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'myapp/static'),
)
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'
PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'
PIPELINE_CSS = {
'base': {
'source_filenames': (
'myapp/css/base.css',
'myapp/bower_components/bootstrap/dist/css/bootstrap.css',
'myapp/bower_components/Hover/css/hover.css',
'myapp/bower_components/font-awesome/css/font-awesome.css',
),
'output_filename': 'css/myapp.css',
},
}
PIPELINE_JS = {
'base': {
'source_filenames': (
'myapp/bower_components/jquery/dist/jquery.min.js',
'myapp/bower_components/bootstrap/dist/js/bootstrap.min.js',
),
'output_filename': 'js/myapp.js',
},
}
My base HTML template contains the following:
{% load staticfiles %}
{% load pipeline %}
<!DOCTYPE html>
<html>
<head>
[...]
{% block css %}
{% stylesheet 'base' %}
{% endblock css %}
{% block javascript %}
{% javascript 'base' %}
{% endblock javascript %}
</head>
<body> [...] </body>
</html>
My home.html extends base.html but does not use the css nor javascript pipeline's template tags.
Just to make sure yuglify is available:
$ yuglify --version
0.1.4
What am I doing wrong here?
Note: browser does not find static assets (myapp.css and myapp.js) if PIPELINE_ENABLED = True
.
dockerhost:8000
, and it mysteriously went away when I changed back tolocalhost:8000
. Sometimes I wonder iflocalhost
doesn't have even higher elevated privileges than just being a default entry in hosts files. – Noctule