gpt4 book ai didi

python - django 管道根本不工作

转载 作者:太空宇宙 更新时间:2023-11-03 11:29:24 24 4
gpt4 key购买 nike

我为此奋斗了几个小时,求求你,帮我解决这个问题,否则杀了我 =(

我看到所有 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>

最佳答案

您需要在每个 source_filenames 后加上逗号。即使它只有 1 个来源。

例如:
'源文件名':(
'main.less' ,
),

不是


'源文件名':(
'main.less'
),

关于python - django 管道根本不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25456970/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com