Hopetree
V2EX  ›  Django

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

  •  
  •   Hopetree ·
    Hopetree · May 2, 2018 · 4626 views
    This topic created in 2946 days ago, the information mentioned may be changed or developed.

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

    2 replies    2018-05-02 21:38:43 +08:00
    darylc
        1
    darylc  
       May 2, 2018 via Android
    感觉没啥好的
    ericls
        2
    ericls  
       May 2, 2018 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.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1120 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 18:20 · PVG 02:20 · LAX 11:20 · JFK 14:20
    ♥ Do have faith in what you're doing.