我在
中有以下代码main.py:
@app.route("/admin")
def admin_panel():
resources = [{'id': '302', 'title': 'Participant 302'}]
events = []
return render_template("admin.html", admin_resources=resources, admin_events=events)
在相应的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返回None。
我对如何解决报价被编码的问题以及为什么{{admin_resources | tojson}}返回无。
有什么想法吗?感谢您的任何建议!
如果执行{{admin_resources |安全}} 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)
答案 0 :(得分:1)
需要进行2项更改: