Use Django template tags in jQuery/Javascript?

前端 未结 3 657
轻奢々
轻奢々 2020-11-29 07:28

Can I use Django\'s template tags inside Javascript? Like using {% form.as_p %} in jQuery to dynamically add forms to the page.

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 08:11

    If you want to use variables inside your rendered javascript I (that's my opnion), think it's a bad idea. But if all you want is to generate URL for your views, media and static files, I do this a lot.

    Take a look to this github: jscssmin

提交回复
热议问题