flask/jinja向javascript发送数组

flask/jinja向javascript发送数组,javascript,python,flask,fullcalendar,jinja2,Javascript,Python,Flask,Fullcalendar,Jinja2,我有下面的代码 main.py: 在相应的html标题中: admin.html $function{//文档准备就绪 $('#calendar').fullCalendar({ today: "12-18-18", editable: true, // enable draggable events aspectRatio: 1.8, scrollTime: '00:00', // undo default 6am scrollTime header: { left

我有下面的代码

main.py:

在相应的html标题中:

admin.html

$function{//文档准备就绪

$('#calendar').fullCalendar({
  today: "12-18-18",
  editable: true, // enable draggable events
  aspectRatio: 1.8,
  scrollTime: '00:00', // undo default 6am scrollTime
  header: {
    left: 'today,prev,next',
    center: 'title',
    right: 'timelineDay,timelineThreeDays,agendaWeek'
  },
  defaultView: 'timelineThreeDays',
  resourceLabelText: 'Participants',

  resources: {{admin_resources}},
  events: {{ admin_events}}
});
})

我得到一个异常,因为资源数组中的引号正在编码。当我尝试{{admin_resources | tojson}}时,我得到一条错误消息,说明tojson不返回任何值

如何解决引号被编码的问题,以及为什么{{admin_resources{124; tojson}}没有返回引号,这让我感到困惑

有什么想法吗?谢谢你的建议

我会注意到,如果我做{{admin_resources | safe}},json似乎编码正确;但是,即使在html中看到json数组,我也会遇到以下错误:

Uncaught TypeError: Cannot read property 'resources' of undefined
    at t.n.Calendar.instantiateView (scheduler.min.js:8)
    at t.renderView (fullcalendar.min.js:10)
    at t.initialRender (fullcalendar.min.js:10)
    at t.render (fullcalendar.min.js:10)
    at HTMLDivElement.<anonymous> (fullcalendar.min.js:11)
    at Function.each (jquery.min.js:2)
    at w.fn.init.each (jquery.min.js:2)
    at w.fn.init.i.fn.fullCalendar (fullcalendar.min.js:11)
    at HTMLDocument.<anonymous> (admin:29)
    at l (jquery.min.js:2)

需要进行两项更改:

日历中今天的日期不能是12-18-18。需要输入正确的格式:“2018-12-18” 需要使用safe设置变量访问。{{admin_resources}安全}
为什么不从API或web服务的异步调用中提供资源和事件变量?不是更容易吗?我希望jinja直接支持这个功能。异步方法似乎需要正确处理日历加载。实际上,在对编辑进行更改后,我想知道资源数组是否真的是一个问题。一个解决方案是使用restful API。最简单的解决方案是使用该工具。
Uncaught TypeError: Cannot read property 'resources' of undefined
    at t.n.Calendar.instantiateView (scheduler.min.js:8)
    at t.renderView (fullcalendar.min.js:10)
    at t.initialRender (fullcalendar.min.js:10)
    at t.render (fullcalendar.min.js:10)
    at HTMLDivElement.<anonymous> (fullcalendar.min.js:11)
    at Function.each (jquery.min.js:2)
    at w.fn.init.each (jquery.min.js:2)
    at w.fn.init.i.fn.fullCalendar (fullcalendar.min.js:11)
    at HTMLDocument.<anonymous> (admin:29)
    at l (jquery.min.js:2)