我想知道是否可以将views.py中的render_to_response中的变量传递给script.js,
render_to_response('appname/basic.html',{'var':somevariable})
我基本上想在 HTML 页面之外访问变量 {{var}},因为我的 script.js 使用类似:
function WillHappen()
{
var n = noty({
text: 'You're {{var}}!',
type: 'warning',
dismissQueue: false,
layout: 'center',
theme: 'defaultTheme'
})
}
如果我将 Javascript 放入 HTML 页面,它会起作用,但我想将它们分开,因为我可能在很多 HTML 页面中使用它。