问题标签 [flask-bootstrap]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
3020 浏览

python-3.x - 通过 Flask-Bootstrap 将 Flask WTForms 验证传递给 Bootstrap Alerts

新的 Flask 用户在这里...我正在为我的 Flask 应用程序构建一个漂亮的文件上传按钮。该按钮本质上使用 WTForms 来验证是否只能上传 csv 和 txt 文件。上传有效,但是如何将验证错误作为引导警报传递到屏幕?例如:

  1. 按下上传按钮将生成警报“未选择文件”
  2. 使用 jpeg 按下上传将生成“错误的文件格式”

任何建议将不胜感激!

我的forms.py:

我的路线.py:

最后是 HTML/CSS/JS:

0 投票
1 回答
6832 浏览

flask - Bootstrap 3.3.7 - 在另一条路线上运行功能时在按钮中加载 gif

我的烧瓶应用程序上有一些按钮,单击时会触发不同路线上的功能。我想在页面等待功能完成时添加加载 gif。我已经尝试了十几个来自 SO 的例子,但我没有运气。注意,我在 bootstrap 3.3.7 所以我不能使用

HTML:用于路由/仪表板(按钮位于此处)

Routes:按钮链接到 run_model 函数,执行并重定向到仪表板页面。

所以本质上,当浏览器“等待127.0.0.1:5000/run_model 完成并被重定向回/dashboard

0 投票
3 回答
2989 浏览

python - jinja2.exceptions.UndefinedError: 'bootstrap_find_resource' 未定义

这是我的第一篇文章,如有错误请见谅...

我正在构建一个 Flask 应用程序并使用 Flask Bootstrap,但我无法找出为什么会出现此错误,因为此方法属于 flask-bootstrap 包的 base.html 模板。

文件“c:\users\diego\documents\repositorios\simpleiotserver\venv\lib\site-packages\flask_bootstrap\templates\bootstrap\base.html”,第 15 行,在“样式”块中

jinja2.exceptions.UndefinedError: 'bootstrap_find_resource' 未定义

似乎一切都按原样完成了,我自己找不到错误。

这是代码...

0 投票
2 回答
5270 浏览

python - Flask - base.html 中的引导程序

我想将 Bootstrap 添加到我的网站。我有 base.html 和其他文件,它们继承自 base.html,但在我的 base.html 中,我希望有导航栏,它将显示在每个站点上。不幸的是,添加一些引导代码后,它没有显示,但是如果我将此代码添加到 index.html,它将显示。

我的base.html:

所以在这种情况下,导航栏不显示。正如我上面写的,如果我将导航类添加到 index.html,导航栏只会显示在这个网站上。我该如何解决?

0 投票
1 回答
1654 浏览

python - How to refresh front page after back-end task completed

I'm design a web application with python flask, the processing flow is like:

  1. User choose a specified a URL, and ask server site to do some time-consuming task;
  2. The time-consuming task is then running in a new thread;
  3. After #2 is done, server will update some info regarding the URL, I need to refresh the page in #1

I don't know how to notify the "completion" status to front-end so as to refresh the page.

Anyone can help me out? Thanks

0 投票
1 回答
710 浏览

python - 无法覆盖flask_bootstrap css

我正在尝试将静态 css 文件添加到我的烧瓶应用程序中。我正在使用flask_bootstrap,但我无法正确实现它-我相信我遵循了文档

https://pythonhosted.org/Flask-Bootstrap/basic-usage.html

但有些不对劲。这是有问题的文件。

初始化.py

base.html

0 投票
2 回答
946 浏览

flask - “Fieldlist”/“FormField”无法使用 flask_wtf 正确渲染

我在带有烧瓶的 wtforms 中使用字段列表,但它们的默认值无法正确呈现。

在下面的示例中,Fieldlist 的 min_entries 值为 1,我通过 append_entry() 方法添加了两个额外的条目。

额外的两个条目无法正确呈现,因为它们的值不再是默认值,而是一些混合了 html 和默认值的丑陋文本。

现在我决定在我的项目中根本不使用字段列表,而是通过 min_entries 生成固定数量的条目,这意味着我不能使用动态数量的条目。

flask 如何呈现 Fieldlist 条目

第一个条目:value="[Enter track number]"
第二个条目:value="<input id="track" name="track" type="text" value="[Enter track number]">"

如何呈现 FieldList 条目

依赖关系和文件夹树

  • 烧瓶:1.0.2
  • 烧瓶引导:3.3.7.1
  • 烧瓶-wtf:0.14.2

文件夹结构:
├── app.py
├── templates
| └── album_add.html

应用程序.py

专辑添加.html

0 投票
2 回答
975 浏览

python - 如何修复模态不显示?

我有一系列 6 个模态,它们是通过烧瓶/jinja2 框架工作循环创建的,还有 1 个模态是循环外的示例。查看页面源时,所有模式都会正确填充和填充。循环外的示例模态显示没有问题,但是其他 6 个模态不会触发。

https://www.sfiltrowani.pl/filter_instructions是有问题的现场。 https://github.com/rscales02/sfiltrowani是完整的代码 git 存储库。

这是针对在 AWS 弹性 beantalk 上运行的烧瓶应用程序。我能够通过手动定义模态 ID 和数据目标来显示示例模态,这些是我从原始模态代码的复制/粘贴和到模态的原始链接所做的唯一更改。

示例链接来自 AF 的相同链接

模态循环为指令创建图像模态

预期结果为我的说明中的每张照片触发的模态。当前结果仅会显示示例模式。

[编辑] 我是堆栈的新手,编辑显示由于缺少缩进而隐藏的 3 行代码。谢谢和抱歉!

0 投票
1 回答
17096 浏览

python - 在使用 Flask for Python 3 时如何使用 Bootstrap 4?

我检查并发现默认情况下安装 Flask-Bootstrap 时,它本机使用 Bootstrap 3.3.7。但实际上我想通过使用 Flask-Bootstrap 包在我的项目中使用 Bootstrap 4+,任何帮助将不胜感激如何更新它或类似的东西。谢谢

0 投票
2 回答
2532 浏览

python - Flask-Talisman breaks Flask-Bootstrap

I want my website to always redirect to the secure https version of the site, and I'm using flask-talisman to do this. However for some reason adding this seemingly-unrelated line of code is breaking the flask-bootstrap formatting on my website.

This is what the original __init__.py file and website looked like before adding flask-talisman:

enter image description here

And this is what the __init__.py file and website look like after adding flask-talisman:

enter image description here

Changing the order of the lines Bootstrap(app) and Talisman(app) doesn't make any difference either. Any ideas? I want my website to be secure, but not at the cost of breaking all of the formatting.