【发布时间】:2017-12-05 05:16:45
【问题描述】:
我是 python 和 Flask 的新手。我目前正在做一个项目,我需要为不同的操作呈现不同的页面,但它们都需要访问同一个对象。
例如:
@app.route("/", methods =['GET','POST'])
def funtionA()
objs = somefunction() // returns an object list
render_template("/results/'+objs+'")
@app.route("/results/<objs>", methods =['GET','POST'])
def functionB(objs)
for obj in objs
print(objs[i].attr)
我可以将字符串、整数甚至路径作为参数传递。我找不到任何参考来查看传递对象是否可行。感谢您的回复!
谢谢, 迪帕克
【问题讨论】:
-
您能否详细说明您需要从一个视图传递到另一个视图的数据?数据是否来自数据库?