Re: django context data into javascript

2020-02-25 Thread 'Artem Vasin' via Django users
.js files, even if linked in Django templates are not processed by template engine. To output value from context to file, this file should be an output from template engine. You have three ways to solve your problem: Make your myjs.js file generated by template processor. It’s most difficult and

Re: django context data into javascript

2020-02-25 Thread Soumen Khatua
But I'm getting one error On Tue 25 Feb, 2020, 5:59 PM Naveen Arora, wrote: > Hi, this is simple just enclose {{name}} into " " as "{{name}}" for your > part. > > Thanks > > On Tuesday, 25 February 2020 15:56:05 UTC+5:30, Soumen Khatua wrote: >> >> Hi Folks, >> >> I'm sending some context data i

Re: django context data into javascript

2020-02-25 Thread Naveen Arora
Hi, this is simple just enclose {{name}} into " " as "{{name}}" for your part. Thanks On Tuesday, 25 February 2020 15:56:05 UTC+5:30, Soumen Khatua wrote: > > Hi Folks, > > I'm sending some context data into html like > name = 'soumen' > return render(request,'xyz.html', context = {'name':name}

Re: django context data into javascript

2020-02-25 Thread Gil Obradors
Hi! The context is a dictionary mapping template variable names to Python objects. from https://docs.djangoproject.com/en/3.0/intro/tutorial03/ May be you need to test with a dict nor string directly. I haven't test a direct variable. Try not using JS, first resolve dict context in html , then J

django context data into javascript

2020-02-25 Thread Soumen Khatua
Hi Folks, I'm sending some context data into html like name = 'soumen' return render(request,'xyz.html', context = {'name':name}) inside myjs.js(js script has been integrated to html): --- var my_name = {{name}}; I'm getting an erro