Пример #1
0
def edit_view(request):
    form = AjaxPersonForm()
    if request.method == 'GET':
        form = AjaxPersonForm(instance=default_person())
    elif request.method == 'POST':
        form = AjaxPersonForm(request.POST, instance=default_person())
        if form.is_valid(): 
            form.save()
            return HttpResponseRedirect('/')
    return render_to_response('person_edit.html', {'form' : form}, context_instance=RequestContext(request))
Пример #2
0
def edit_ajax_view(request):
    if request.method == 'POST':
        if request.user.is_authenticated():
            form = AjaxPersonForm(request.POST, instance=default_person())
            if form.is_valid(): 
                form.save() 
            return HttpResponse(form.as_p_with_submit())
        else:
            return HttpResponseForbidden('Login required!')
    else:
        return HttpResponseNotAllowed(['POST'])