flask渲染模板时报错TypeError: 'UnboundField' object is not callable

渲染模板时,访问页面提示TypeError: ‘UnboundField‘ object is not callable

检查代码,发现实例化表单类是,没有加括号:form = NewNoteForm,加了括号后就解决了form = NewNoteForm()

@app.route(‘/index‘)def index():    form = NewNoteForm    notes = Note.query.all()    return render_template(‘index.html‘, notes=notes, form=form)

flask渲染模板时报错TypeError: 'UnboundField' object is not callable

原文地址:https://www.cnblogs.com/xiaxiaoxu/p/10581522.html

时间: 2024-10-01 05:16:25

flask渲染模板时报错TypeError: 'UnboundField' object is not callable的相关文章

TypeError: 'str' object is not callable

Python报错TypeError: 'str' object is not callable TypeError: 'str' object is not callable

statsmodels.tsa.arima_model预测时报错TypeError: int() argument must be a string, a bytes-like object or a number, not 'Timestamp'

在 python 中用 statsmodels创建 ARIMA 模型进行预测时间序列: import pandas as pd import statsmodels.api as sm df = pd.read_csv("data.csv", index_col=0, parse_dates=True) mod = sm.tsa.statespace.SARIMAX(df['price'], enforce_stationarity=False, enforce_invertibili

python框架Scrapy报错TypeError: 'float' object is not iterable解决

原因是:Twisted版本高了. 解决办法: 只要把Twisted库降级到16.6.0即可: 1 pip3 install Twisted==16.6.0 2 3 注:Twisted16.6.0安装后,会自动卸载高版本的Twisted python框架Scrapy报错TypeError: 'float' object is not iterable解决

Python2.7 在使用BSTestRunner.py时报错TypeError: unicode argument expected, got 'str'

python3往这个库中加入了一些新的内容,使得该库在Python2.7中报错. 解决方法是将导入语句 from io import StringIO as StringIO 更换为: from io import BytesIO as StringIO   Python2.7 在使用BSTestRunner.py时报错TypeError: unicode argument expected, got 'str'

zc.buildout构建项目时报错‘AttributeError: '_NamespacePath' object has no attribute 'sort'’

在使用zc.buildout构建项目时如果碰到'AttributeError: '_NamespacePath' object has no attribute 'sort''报错: An internal error occurred due to a bug in either zc.buildout or in a recipe being used: Traceback (most recent call last): File "c:\python36\lib\site-package

python 报错TypeError: 'range' object does not support item assignment,解决方法

贴问题 nums = range(5)#range is a built-in function that creates a list of integers print(nums)#prints "[0,1,2,3,4]" print(nums[2:4])#Get a slice from index 2 to 4 (exclusive); prints '[2,3]" print(nums[2:])#Get a slice from index 2 to the end

执行python manage.py makemigrations时报错TypeError: __init__() missing 1 required positional argument: 'on_delete'

在执行python manage.py makemigrations时报错: TypeError: __init__() missing 1 required positional argument: 'on_delete' 解决方法: 在连接外键时加上: on_delete=models.CASCADE 执行python manage.py makemigrations时报错TypeError: __init__() missing 1 required positional argument

python 报错——Python TypeError: 'module' object is not callable 原因分析

原因分析:Python导入模块的方法有两种: import module 和 from module import 区别是前者所有导入的东西使用时需加上模块名的限定,而后者则不需要 例: >>>import pprint >>>pprint.pprint(people) OR >>>from pprint import * >>>pprint(people) 正确的代码:>>> import Person>&g

facenet pyhton3.5 训练 train_softmax.py 时报错AttributeError: 'dict' object has no attribute 'iteritems'

报错原因:在进行facenet进行train_softmax.py训练时,在一轮训练结束进行验证时,报错AttributeError: 'dict' object has no attribute 'iteritems' 解决方案:由于我的python时3.5的,Python3.5中:iteritems变为items,找到train_softmax程序修改如下: facenet pyhton3.5 训练 train_softmax.py 时报错AttributeError: 'dict' obj