YUCOAT
V2EX  ›  问与答

能不能把Django模板的部分变量写入settings.py中,比如SITE_NAME

  •  
  •   YUCOAT · Aug 19, 2012 · 3012 views
    This topic created in 5100 days ago, the information mentioned may be changed or developed.
    几乎每个模板都会用到SITE_NAME这个变量,如果每次都把这个变量传入render_to_response函数中显然有点不合理,所以我想问一下能不能把它写进settings.py中,然后通过某种方法直接在模板中使用这个变量
    2 replies    1970-01-01 08:00:00 +08:00
    freetstar
        1
    freetstar  
       Aug 19, 2012
    直接在settings.py中写SITE_NAME=xxx,然后import settings ,不知道是不是这个意思
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3486 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 04:59 · PVG 12:59 · LAX 21:59 · JFK 00:59
    ♥ Do have faith in what you're doing.