Django Template Variables and Javascript

后端 未结 15 2809
误落风尘
误落风尘 2020-11-22 05:59

When I render a page using the Django template renderer, I can pass in a dictionary variable containing various values to manipulate them in the page using {{ myVar }}

15条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 06:19

    The {{variable}} is substituted directly into the HTML. Do a view source; it isn't a "variable" or anything like it. It's just rendered text.

    Having said that, you can put this kind of substitution into your JavaScript.

    
    

    This gives you "dynamic" javascript.

提交回复
热议问题