[Django]-Setting global variables with Cactus App for Mac

0👍

Cactus has a ‘config’ tag that lets you access variables specified in the config.json file.

So if your config.json contains the following line:

“email”: “webmaster@example.com”,

…then in your templates, you can reference this with:

{% config “email” %}

Hope this answer was worth the 18 month wait!

👤Anton

0👍

@Anton answer works fine for printing global variables, but… for using them on blocks is better to put them on context entry in config.json. This way you can access them on the templates way easier.

If you want to do:

<meta name="author" content="{{ blog.author }}">

Declare in config.json:

{
  ...
  "context": {
    "blog": {
      "id": "fancy-site",
      "author": "Joe Blogs",
      "description": "Such a fancy site"
    }
  }
}

Source: https://github.com/eudicots/Cactus/issues/125

You can use this for arrays too. It’s JSON. I use it for declaring nested menus, for instance, iterating with for loop block.

Leave a comment