问题

在使用flask-bootstrap渲染表单时,报错AttributeError: module 'dominate.tags' has no attribute 'input'

解决方法

修改\venv\Lib\site-packages\flask_bootstrap\forms.py,也就是修改安装的第三方库源码。把tags.input改成tags.input_

tags.input(type=type, _class=' '.join(classes), **kwargs)
改成
tags.input_(type=type, _class=' '.join(classes), **kwargs)
其他地方类似改法

排错记录

报错提示是dominate.tags 没有input属性(或者是个方法?),但是之前很少接触dominate.tags ,不妨完整检查一下。
从下图错误堆栈情况可以看到,是在返回渲染表单时出现了错误。

  1. 先检查一下表单有没有问题,
    form.py
from flask_wtf import FlaskForm
from wtforms import StringField, SubmitField, PasswordField
from wtforms.validators import DataRequiredclass LoginForm(FlaskForm):user_id = StringField("请输入学号:", validators=[DataRequired()])name = PasswordField("请输人姓名:", validators=[DataRequired()])submit = SubmitField('提交')

很简单的一个表单,应该没有问题。

  1. 再看看app.py
@app.route('/login', methods=['GET', 'POST'])
def login():form = LoginForm()return render_template('login.html',form=form)

同样很常规。(其实这两步没必要,因为错误堆栈从最下面看可以一步定位)。

  1. 直接检查一下tag引用的源文件\venv\Lib\site-packages\dominate\tags.py
class input_(html_tag):'''The input element represents a typed data field, usually with a form controlto allow the user to edit the data.'''is_single = True
_input = input_

发现没有input这个类了,改成了input_

查看了dominate的源码,发现2020年就改了,而flask-bootstrap的库很久没维护了。

【Flask】flask-bootstrap报错AttributeError: module ‘dominate.tags‘ has no attribute ‘input‘解决方法相关推荐

  1. python报错AttributeError module ‘scipy.misc‘ has no attribute ‘imresize‘和 ‘imread‘

    python报错AttributeError: module 'scipy.misc' has no attribute 'imresize'和 'imread' 报错原因:scipy版本过高 解决方 ...

  2. AttributeError: module ‘cv2.cv2‘ has no attribute ‘xfeatures2d‘解决方法

    运行一段关于图像拼接的代码时,出现问题 AttributeError: module 'cv2.cv2' has no attribute 'xfeatures2d' def __init__(sel ...

  3. python 报错 AttributeError: module ‘time‘ has no attribute ‘clock 解决方法

    源码如下: #引入所需要的时间库 import datetime import time#程序计时器,启动计时器 start = time.clock()#中间是放置需要测试运行时间的程序代码#计算启 ...

  4. 第一:Python+Allure运行报错AttributeError: module ‘allure‘ has no attribute ‘severity_level‘

    1.很多查询结果都是先卸载pytest-allure-adaptor,然后再安装allure-pytest pip3 uninstall pytest-allure-adaptor 2.pip3 in ...

  5. python中引入包的时候报错AttributeError: module ‘sys‘ has no attribute ‘setdefaultencoding‘解决方法?

    python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法? 参考文章: (1)pyth ...

  6. pyinstall :打包 .exe 文件报错AttributeError: module ‘enum‘ has no attribute ‘IntFlag‘

    有疑问的地方 参考博文 一.环境搭建 Python GUI图形化小工具编程学习-- PySide2 环境搭建(一) 二.实例演示 Python GUI图形化小工具编程学习-- Demo 实例演示(二) ...

  7. 报错:Parameter ‘XXX‘ implicitly has an ‘any‘ type.解决方法

    报错:Parameter 'XXX' implicitly has an 'any' type.解决方法 tsconfig.json添加"noImplicitAny": false ...

  8. 【报错】node:internal/modules/cjs/loader:936 【解决方法】

    1.报错问题 执行完 npm install 之后执行  npm start 时,会显示code: 'MODULE_NOT_FOUND'  Error: Cannot find module '~\h ...

  9. svn update 报错,必须先cleanup,然后cleanup失败解决方法

    svn update 报错,必须先cleanup,然后cleanup失败解决方法 参考文章: (1)svn update 报错,必须先cleanup,然后cleanup失败解决方法 (2)https: ...

最新文章

  1. 深入jvm虚拟机第4版_深入JVM虚拟机,阿里架构师直言,这份文档真的是JVM最深解读...
  2. Linux下的软raid实验一例
  3. Ubuntu 18.04 + Anaconda 5.2 + Pycharm
  4. 关于ReetrantLock
  5. H.264的两个概念:DC系数和AC系数。 MV预测过程详解(附图)
  6. ddos应急处理_写给十九大安保应急的兄弟们 来看看DDOS攻击应急预案
  7. 我来重新学习 javascript 的面向对象(part 1)
  8. Windows8 游戏开发教程-二、关于资源和工具
  9. 以虚拟现实骨灰级开发者视角,来看VR智能硬件平台
  10. 吴恩达 Drive.ai 因经营困难“卖身”苹果
  11. FL Studio新手教程:FL Studio五大常用按钮介绍
  12. Python之pygame安装教程
  13. 【OpenCV学习】cvtColor
  14. 第十三周助教心得体会
  15. android简单点餐系统_微信点餐收银系统哪个好用?
  16. r语言html乱码,R语言:读入txt文件中文文本出现乱码解决方案
  17. 辨别身份真假之【天眼数聚】腾讯云身份证实名认证接口
  18. 学习笔记——Exploiting Unintended Feature Leakage in Collaborative Learning(协作学习中的非预期特征泄露研究)
  19. 两个路由器如何通过一根网线组建局域网(非wifi桥接方式)
  20. python稳健性检验_有哪些比较好的做异常值检测的方法?

热门文章

  1. Java码农怎样才能成为年薪60W的高级架构师进入BAT?
  2. 制作动态相册的python知识点_动感网页相册 python编写简单文件夹内图片浏览工具...
  3. 转:苹果企业级开发者账号申请流程
  4. 回顾Object.defineproperty
  5. MacBook Pro有哪些快捷键!(最全新版)
  6. 静态页面下,页面编码为gb2312,但是源代码中出现大量/uxxxx的解决方法
  7. C# 利用pictureBox做音乐播放和暂停播放,继续播放按钮
  8. mac安装windows虚拟机并且进行远程连接
  9. 什么是放量和缩量,什么是成交量
  10. 程序员不了解这些投简历的巨坑,面试注定一开始就失败!