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

django 有类似于 flask 里面 @app.shell_context_processor 的装饰器吗?

  •  
  •   Hopetree ·
    Hopetree · 2018-05-02 17:41:40 +08:00 · 3842 次点击
    这是一个创建于 2179 天前的主题,其中的信息可能已经有所发展或是发生改变。

    @app.shell_context_processor 这个装饰器可以把函数里面的内容添加成 flask 的 shell 上下文,这样可以减少开启 shell 的时候重复导入模块的步骤,请问 django 有类似的用法吗?我只知道 django 有模板上下文管理器,那个我用过,但是没有找到 shell 的上下文管理器,我感觉这个挺有用的啊

    2 条回复    2018-05-02 21:38:43 +08:00
    susecjh
        1
    susecjh  
       2018-05-02 18:01:06 +08:00 via Android
    感觉没啥好的
    ericls
        2
    ericls  
       2018-05-02 21:38:43 +08:00 via iPhone
    shell_plus from django-extensions

    Not a decorator but can achieve the the same thing.
    In fact, I don ’ t think it ’ s a good practice to intertwine your app code and dev tool.
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1007 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 19:04 · PVG 03:04 · LAX 12:04 · JFK 15:04
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.