mako how to access STATIC_URL (in django)

90 views
Skip to first unread message

mengdexin

unread,
Sep 20, 2012, 10:41:07 PM9/20/12
to mako-d...@googlegroups.com
In django, template can access  {{ STATIC_URL }} defined in setting.py.

When use Make in django, how to achive it ?

thank u.

Jeffrey Jenkins

unread,
Sep 21, 2012, 2:02:15 PM9/21/12
to mako-d...@googlegroups.com
You should add STATIC_URL into the context object you're passing in to be rendered.  I often write a wrapper around the mako template loading/rendering code which lets me add common variables like that so that every template has access to them.

Alternatively (but I think less preferable) you could just import STATIC_URL from settings in a <%%> block.
Reply all
Reply to author
Forward
0 new messages