- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在运行 Django 1.8.2,我正在使用 django-pipeline 1.5.1 来收集和压缩我的 CSS 和 JS 文件。
运行 python manage.py collectstatic
后,Django 收集所有文件并按配置压缩它们。但是当我想访问网络服务器时,开发服务器不会为所有静态文件提供服务。即无法加载来自 django-pipeline 的那些。
我的模板是这样的:
{% load pipeline %}
...
{% javascript 'master' %}
当页面在开发服务器中加载时,Django 将代码转换为:
<script charset="utf-8" src="/static/compressed/master.js" type="text/javascript"></script>
<link href="/static/img/favicon.ico" rel="icon"></link>
到目前为止,这还不错。但是无法提供管道中的文件:
"GET /static/compressed/master.js HTTP/1.1" 404 1774
但是我可以在我的静态文件夹中看到失败的 master.js
:
static
├── compressed
│ └── master.js
│ └── ...
└── img
└── favicon.ico
为什么提供了网站图标,但没有提供压缩文件?我关注了official tutorial并仔细检查它。感谢您的帮助。
添加该站点运行良好,通常提供静态文件。该问题只发生在来自 django-pipeline 的压缩文件中。
相关设置
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)
最佳答案
static
文件夹位于何处?
如果它在 BASE_DIR
之外,我的意思是,在 up 文件夹中,您可能必须在此处声明路径
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'templates/dpb'),
)
在 django 1.8 中,我真的没有看到使用 STATIC_ROOT
的必要性,因为 STATICFILES_DIRS
对于在任何地方统一静态目录非常有用。
考虑此命令的输出 os.path.join(BASE_DIR, 'templates/dpb')
找出错误的一个好方法是启动 pdb 调试器,以便像 Django 那样查看。
在 STATICFILES_DIRS
语句之后设置一个断点:
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'templates/dpb'),
)
import pdb; pdb.set_trace()
像这样运行你的服务器:
python -m pdb manage.py runserver
这将在您的问题中停止 django 加载程序,从而轻松打印出 STATICFILES_DIR 并显示 Django 正在寻找这些文件的位置。
如有疑问,look for more .
关于python - Django 1.8.2 不提供所有静态文件 - django-pipeline,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30955183/
例如,如果运行 1 正在等待批准并触发运行 2,则应拒绝运行 1。 最佳答案 “待批准”状态具体来自 Approval Gates功能。 虽然您不能在触发新运行时明确拒绝“待批准”步骤,但您可以通过在
在 Azure DevOps Pipelines 中,似乎有两种我无法区分的概念和处理“工件”的方法。 管道工件 https://learn.microsoft.com/en-us/azure/dev
不确定是否有办法做到这一点,但我想查看之前运行的 yaml 管道中的参数,以便查看管道运行时输入或选择的内容。那可能吗?我发现的唯一解决方法是根据每个参数添加标签。 最佳答案 您可以从 Build 查
我正在运行我所有的测试用例,其中一些用例有时会失败,管道检测到它并使步骤和构建失败。这会阻止要执行的下一步(压缩报告文件夹)。我想将该 zip 文件作为电子邮件附件发送。 这是我的 bitbucket
我正在数据工厂中定义管道,我纠正了一些错误。第一个事件是调用 usql 脚本进行一些聚合,我更改了脚本很多时间,但错误仍然是: [{"errorId":"E_CSC_USER_SYNTAXERROR"
我正在尝试使用运行命令VSTS扩展名对VSTS版本定义执行helm命令,但问题是它无法在我配置的自定义生成代理上找到kubeconfig文件。我认为这是因为定义的构建步骤在单独的过程中运行。当我运行
我无法弄清楚 sklearn.pipeline.Pipeline 是如何工作的。 doc 中有一些解释.例如它们是什么意思: Pipeline of transforms with a final e
我在 azure 管道中有两个管道(也称为“构建定义”),一个正在执行系统测试,一个正在执行性能测试。两者都使用相同的测试环境。我必须确保系统测试管道运行时不会触发性能管道,反之亦然。 到目前为止我已
我遵循了这个指令 https://confluence.atlassian.com/bitbucket/use-ssh-keys-in-bitbucket-pipelines-847452940.ht
当使用 YAML 完成另一个管道时尝试触发 Azure 管道。有documentation表明您可以添加管道资源: resources: # types: pipelines | builds |
我正在尝试根据我发布到的每个环境对我的 Web.config 进行文件转换。大多数情况下,一切看起来都很好,直到我在发布管道上部署到我的 UAT 阶段。 在我的构建管道中,这是我正在使用的 YAML
脚本化管道中是否有任何方法可以将某个阶段标记为不稳定,但仅将该阶段显示为不稳定,而不在输出中将每个阶段标记为不稳定? 我可以做这样的事情: node() { stage("Stage1") {
我有针对特定环境(dev、qa、uat)的特定配置文件和另一个根 web.config。部署的代码读取 web.config。所以我一直在尝试复制内容或重命名 Azure Pipelines 中的文件
我的 Jenkins 中有很多 Pipeline 项目。我想将它们转换为多分支管道。是否可以不删除管道并创建新的多分支管道?怎么办? 最佳答案 假设您的管道位于 Jenkinsfile 中,则无需进行
我们正在使用扩展功能以安全的方式在我们的管道中重用模板。为了更轻松地定义模板的参数,我想使用变量,但我觉得这是不可能的。 但由于我在官方文档中找不到答案,所以我在这一轮提问。 我的 yml 文件如下所
如何访问UID Jenkins 管道工作中的变量? 我收到了 null什么时候: pipeline { agent any environment { def user
我正在摆弄管道以尝试减少整体运行时间。我想做的一件事是执行 docker pull ...在开始时,以便以后,当我真正需要它时,它已经为我准备好了。我想将它作为后台工作解雇,并让它在该任务结束后继续存
From here我了解到 Bitbucket Pipeline 支持 ifs 语句。 如何在 if 语句中执行多行块? 这不计算: script: - if [ $BITBUCK
我在运行 Jenkins 服务器(在 docker 容器内)的谷歌云中运行虚拟机。我正在尝试为我的应用程序构建一个 Docker 镜像,并使用 Jenkins 管道将其推送到 Google Conta
在构建和部署 docker image.Getting Unexpected value 'Steps' 在第 27 行之前,我试图将视频文件从 GPM 复制到 app/dist/asset/imag
我是一名优秀的程序员,十分优秀!