我是新來使用fullcalendar,我不能很滿腦子都轉動JSON請求在日曆上繪製JSON來fullcalendar對象
我的模型,而不是使用標題,開始,結束和ALL_DAY
是不是使用的名稱,起始日期,COMPLETION_DATE,ALL_DAY
結果日曆不會呈現來自我的模型對象到fullcalendar
我views.py是
def view_calendar(request):
jobs = Job.objects.all()
return HttpResponse(events_to_json(jobs), content_type='application/json')
本正在生成顯示爲
[{"completionDate": "2015-11-06", "startDate": "2015-11-06", "allDay": false, "name": "342345", "id": 7}, {"completionDate": "2017-04-30", "startDate": "2017-02-19", "allDay": false, "name": "Calendars", "id": 9},
{"completionDate": "2015-02-28", "startDate": "2015-02-26", "allDay": false, "name": "Lowe's Remodel ", "id": 4}, {"completionDate": "2015-02-04", "startDate": "2015-01-18", "allDay": false, "name": "Lowe's Remodel 2", "id": 1},
{"completionDate": "2015-09-13", "startDate": "2015-05-13", "allDay": false, "name": "Lowe's Remodel 3", "id": 5}, {"completionDate": "2017-04-30", "startDate": "2017-04-21", "allDay": false, "name": "WONDER", "id": 10},
{"completionDate": "2015-09-03", "startDate": "2015-08-03", "allDay": false, "name": "aaa gfdsgfs dgfgsd daaa gfdsgfs dgfgsd daaa gfdsgfs dgfgsd daaa gfdsgfs dgfgsd d", "id": 6},
{"completionDate": "2016-04-22", "startDate": "2015-02-24", "allDay": false, "name": "dgfs3344", "id": 3},
{"completionDate": "2015-02-26", "startDate": "2015-02-01", "allDay": false, "name": "gfdgdfs", "id": 2},
{"completionDate": "2015-11-06", "startDate": "2015-11-06", "allDay": false, "name": "ssssgf", "id": 8}]
我不知道如何將這個對象渲染到fullcalendar因爲似乎採取這些論點即使有這樣的JSON
不JSON對象我欣賞這些答案,但我可能沒有澄清,我已經解析我的模型到fullcalendar格式與
`return HttpResponse(events_to_json(jobs).replace('name', 'title').replace("startDate", "start").replace('completionDate', 'end'), content_type='application/json')`
在Django這r enders一個url/output /它傾倒所有這些值,如 [{"end": "2015-11-06", "start": "2015-11-06", "title": "342345"}, {"end": "2015-02-28", "start": "2015-02-26", "title": "Lowe's Remodel "}, {"end": "2015-02-04", "start": "2015-01-18", "title": "Lowe's Remodel 2"}, {"end": "2015-09-13", "start": "2015-05-13", "title": "Lowe's Remodel 3"}, {"end": "2015-09-03", "start": "2015-08-03", "title": "aaa gfdsgfs dgfgsd daaa gfdsgfs dgfgsd daaa gfdsgfs dgfgsd daaa gfdsgfs dgfgsd d"}, {"end": "2016-04-22", "start": "2015-02-24", "title": "dgfs3344"}, {"end": "2015-02-26", "start": "2015-02-01", "title": "gfdgdfs"}, {"end": "2015-11-06", "start": "2015-11-06", "title": "ssssgf"}]
我的問題是如何返回這個包含準備使用json格式的URL到我的Fullcalendar事件中?
@dentemm說了什麼 - 另外,如果您只需使用用於生成JSON作爲事件源的URL端點,則可以在成功回調中將實際的JSON重新格式化爲fullcalendar接受的內容。 –