[英]Using regrouped variable of django template in javascript
From my view function, I have sent some data to django template. 从我的视图函数中,我已经向django模板发送了一些数据。 In the template, data are grouped using regroup method.
在模板中,使用重组方法对数据进行分组。
{% regroup data|dictsort:"month" by month as data_month_list %}
Is there any way to use the data_month_list in javascript? 有什么办法可以在javascript中使用data_month_list?
Figured it out. 弄清楚了。 Actually it was simple.
其实很简单。 At first I was trying to assign the value directly to my js code.
起初,我试图将值直接分配给我的js代码。 Later I declared a variable in django template, assigned the data_month_list in the variable and used it in my js code.
后来我在Django模板中声明了一个变量,在变量中分配了data_month_list并在我的js代码中使用了它。 Now it works.
现在可以了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.