我为此奋斗了几个小时,请帮我解决这个问题或杀了我=(
我正在查看所有 4 个文件的 404。任何地方都没有编译文件。
virtualenv 中的 Python 3.4.0,Django 1.7 RC3。
顺便提一句:
python manage.py collectstatic
将所有内容从 assets 复制到 assets_compressed,并在那里添加管理样式。但是最后有一个错误:
ValueError: The joined path (/) is located outside of the base path component (/home/val/Programming/Django/nedviga/nedviga/assets)
设置:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'pipeline',
)
...
STATIC_URL = '/assets/'
STATIC_ROOT = os.path.join(BASE_DIR, 'assets_compressed')
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'assets'),
)
...
PIPELINE_ENABLED = True
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'
PIPELINE_JS_COMPRESSOR = 'pipeline.compressors.yuglify.YuglifyCompressor'
PIPELINE_COMPILERS = (
'pipeline.compilers.less.LessCompiler'
)
PIPELINE_CSS = {
'libs': {
'source_filenames': (
'libs/bootstrap/css/bootstrap.min.css'
),
'output_filename': 'css/libs.css'
},
'site': {
'source_filenames': (
'main.less'
),
'output_filename': 'css/main.css'
}
}
PIPELINE_JS = {
'libs': {
'source_filenames': (
'libs/jquery/jquery-2.1.1.min.js'
'libs/bootstrap/js/bootstrap.min.js'
),
'output_filename': 'js/libs.js'
},
'site': {
'source_filenames': (
'main.js'
),
'output_filename': 'js/main.js'
}
}
目录结构:
project_name
assets
libs
...
main.js
main.less
assets_compressed
*empty*
project_name
manage.py
看法:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>AAARGH</title>
{% load compressed %}
{% compressed_css 'libs' %}
{% compressed_css 'site' %}
</head>
<body>
{% compressed_js 'libs' %}
{% compressed_js 'site' %}
</body>
</html>