I've followed this tutorial to make a sample project. The structure of the files is:
- mysite
- mysite
- __init__.py
- settings.py
- urls.py
- wsgi.py
- polls
- migrations
- templates
- polls.html
- static
- script.js
- style.css
- admin.py
- models.py
- tests.py
- urls.py
- views.py
- manage.py
Everything works well, but, the problem is using of Django-pipeline for managing the assets. I've configured my project as same as below codes, but it doesn't load assets properly.
settings.py
INSTALLED_APPS = (
.
.
'django.contrib.staticfiles',
'pipeline',
'polls',
)
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static_files')
PIPELINE_ENABLED = True
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.cssmin.CSSMinCompressor'
PIPELINE_CSSMIN_BINARY = 'cssmin'
PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.slimit.SlimItCompressor'
PIPELINE_CSS = {
'pollsX': {
'source_filenames': (
'style.css',
),
'output_filename': 'styles1.css',
'variant': 'datauri',
},
}
PIPELINE_JS = {
'pollsX': {
'source_filenames': (
'script.js',
),
'output_filename': 'scripts1.js',
}
}
polls.html
{% load compressed %}
{% compressed_css 'pollsX' %}
<div class='red-me'>
<h1> Hi! I'm a templ! </h1>
</div>
style.css
.red-me {
color: red;
}
The generated output for http://127.0.0.1/polls
is
<link href="/static/styles1.css" rel="stylesheet" type="text/css" />
<div class='red-me'>
<h1> Hi! I'm a templ! </h1>
</div>
It can not load /static/styles1.css
file in the browser. Even, I tested ./manage.py collectstatic
without any success. Did I miss something?
Python-3.4 and Django-1.7