Django: fullcalendar drag events and save -
i 'm trying drag events , store them in database getjson
javascript file :
<script type='text/javascript'> function savemydata(event, daydelta, minutedelta) { $.getjson("{% url events_drag %}", {'title': event.title, 'start': event.start, 'end': event.end}, function(data) { }); } </script> <script type='text/javascript'> $(document).ready(function() { $('#eventfiltercalendar').fullcalendar({ eventdrop: function(event, daydelta, minutedelta) { savemydata(event); }, eventresize: function (event, daydelta, minutedelta) { savemydata(event); }, </script>
views :
def eventsdrag(request): print 'events...' untitre= request.get['title'] unstart= request.get['start'] unend= request.get['end'] print 'untitre', untitre print 'unstart', unstart print 'unend', unend event.title = untitre event.start = unstart event.end = unend event.save() event_list = [] event_list.append({ ... 'start': event.start, 'end': event.end, 'title': event.title, }) return http.httpresponse(json.dumps(event_list), content_type='application/json')
model :
class event(models.model): title = models.charfield(_(u"nom de l'étude"), max_length=100) start = models.datetimefield(_(u"début")) end = models.datetimefield(_('fin'))
the function eventdrag should read event.title, event.start, event.end , save them in database
but request.get don't work..i display 'events..' , nothing else..
Comments
Post a Comment