我是新来使用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接受的内容。 –