Javascript variables in Django HTML templates

后端 未结 3 1985
甜味超标
甜味超标 2021-01-19 03:41

I\'m writing a Django app and while somewhat familiar with Django I\'m pretty unfamiliar with JavaScript. I\'m adding a few lines of JavaScript into one of my pages in orde

3条回答
  •  野的像风
    2021-01-19 04:11

    Yep that's bad practice.

    Consider defining static folder for your app as described on official django documentation page: Managing static files and upload your js via static template tag.

    You could get data which in {{ info }} variable by creating separate django view which would return JsonResponse and then perform AJAX Request to fetch desired data from newly createdd js file.

提交回复
热议问题