У меня есть следующий код в
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 () {// document ready
$('#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}} возвращает None.
Есть мысли?Спасибо за любые предложения!
Я отмечу, если я сделаю {{admin_resources |safe}} json кажется правильно закодированным;Тем не менее, я получаю следующую ошибку, хотя я вижу массив json в HTML:
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)