How to use the context variables passed from Django in javascript?

前端 未结 3 876
盖世英雄少女心
盖世英雄少女心 2021-01-27 03:52

I am having a method in views.py as follows:

def index(self, request):
    initial = get_initial()
    context = {\"context\" : initial_topics}
    template = lo         


        
3条回答
  •  情歌与酒
    2021-01-27 04:38

    If the javascript code lies in the html template being rendered, you can use it in the normal way {{ context }}. Else, declare a global in the html template and access that global from your separate js file.

提交回复
热议问题