List variable containing string not getting rendered in Django Template

拜拜、爱过 提交于 2019-12-13 03:39:50

问题


I have a list of names, which I render at two different places in a HTML at one place it works fine, the other time it disappears.

names= ['a','b','c','d']

In the HTML code I am printing

{{names}} 

this gives me the correct results. When I use the same string in a javascript it stops working but if I replace the variable by

['a','b','c','d']

then it works fine.


回答1:


What do you mean 'in a javascript'? Is that in a template being rendered by Django, and if not how are you expecting it to be evaluated?



来源:https://stackoverflow.com/questions/2094835/list-variable-containing-string-not-getting-rendered-in-django-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!