如何在django视图之间传递或共享变量? [英] How do you pass or share variables between django views?
问题描述
我有点失落,如何做到这一点:
I'm kind of lost as to how to do this:
我有一些链接的选择框,每个视图有一个选择框。应保存每个选项,以便建立查询。最后,应该运行查询。
I have some chained select boxes, with one select box per view. Each choice should be saved so that a query is built up. At the end, the query should be run.
但是,如何在django中共享状态?我可以从视图传递到模板,但不能模板查看,而不是查看。或者我真的不知道如何做到这一点。请帮助!
But how do you share state in django? I can pass from view to template, but not template to view and not view to view. Or I'm truly not sure how to do this. Please help!
推荐答案
您可以将这些信息存储在会话,因为Ignacio Vazquez-Abrams表示或使用 django-flash - ( django-flash usage )
You can store such information in session as Ignacio Vazquez-Abrams said or use django-flash - (django-flash usage)
这篇关于如何在django视图之间传递或共享变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!