Пример #1
0
def post_create_ajax(request):
    print 'in ajax view'
    print request.POST
    text = request.POST['data']
    #print request.POST
    response = {'status' : 'E'}
    try:
        print 'got text %s' % text
        post = Post(data=text)
        post.save()
        print 'got here'
        response['status'] = 'S'
        print 'and here'
    except:
        pass
    json = simplejson.dumps(response)
    return HttpResponse(json, mimetype='application/json')
Пример #2
0
def post_form(request):
    print 'in post_form'
    if request.is_ajax():
        print 'in post_form ajax'
        text = request.POST['data']
        response = {'status' : 'E'}
        try:
            print 'got text %s' % text
            post = Post(data=text)
            post.save()
            print 'got here'
            response['status'] = 'S'
            print 'and here'
        except:
            pass
        json = simplejson.dumps(response)
        return HttpResponse(json, mimetype='application/json')
        pass
    
    print 'in post_form'
    return create_update.create_object(
                    request,
                    model=Post,
                    post_save_redirect='/posts')