V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
kaiger
V2EX  ›  Flask

flask 视图之间如何传递 class 实例 ?

  •  
  •   kaiger · 2022-09-12 17:27:06 +08:00 · 1430 次点击
    这是一个创建于 584 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如题,在其中一个视图实例化一个 class ,如何将这个实例传递到下一个视图?

    5 条回复    2023-09-05 17:50:11 +08:00
    ericls
        1
    ericls  
       2022-09-12 21:49:52 +08:00 via iPhone
    存到 thread global ?
    Kuhahku
        2
    Kuhahku  
       2022-09-12 22:47:12 +08:00
    dayeye2006199
        3
    dayeye2006199  
       2022-09-13 14:23:10 +08:00
    实现一个序列化方法,比如把 class 转成一个 json ,然后传到另外的一个 view 里面。
    另外一个 view 里面反序列化成一个 class 实例
    ideacco
        4
    ideacco  
       2022-09-13 16:17:32 +08:00
    使用全局变量
    XueXianqi
        5
    XueXianqi  
       226 天前
    g
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5633 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 02:03 · PVG 10:03 · LAX 19:03 · JFK 22:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.