def ajaxsubmit(request): new_msg = Message(msg = request.POST['msg'], posted_by = request.POST['posted_by']) new_msg.save() # Again, we're just going to assume this always works cmd = [{'cmd': 'inlinepush', 'params': { 'password': settings.APE_PASSWORD, 'raw': 'postmsg', 'channel': 'messages', 'data': { 'msg': new_msg.msg, 'posted_by': new_msg.posted_by, 'timestamp': new_msg.timestamp } } }] url = settings.APE_SERVER + urllib2.quote(json.dumps(cmd)) response = urllib2.urlopen(url) # Updating the message is handled by APE, so just return an empty 200 return HttpResponse()