예제 #1
0
def add(request):
    if request.method == "POST":
        form = PublisherForm(request.POST)
        if form.is_valid():
            publisher = form.save()
            publisher.save()
            return HttpResponseRedirect(reverse("index"))
    return render(request, 'books/edit.html', {'form': PublisherForm()})
예제 #2
0
파일: views.py 프로젝트: qq40660/chatrobot
def add(request):
    if request.method=="POST":
        form = PublisherForm(request.POST)
        if form.is_valid():
            publisher=form.save()
            publisher.save()
            return HttpResponseRedirect(reverse("index"))
    return render(request, 'books/edit.html', {'form': PublisherForm()})
예제 #3
0
파일: views.py 프로젝트: qq40660/chatrobot
def edit(request, id):
    publisher = get_object_or_404(Publisher, id=id)
    if request.method == 'POST':
        appForm = PublisherForm(request.POST, instance = publisher)
        if appForm.is_valid():
            publisher = appForm.save();
            publisher.save()
            return HttpResponseRedirect(reverse("index"))
            
    #return render_to_response('books/edit.html', {'form': PublisherForm(instance = publisher)}, context_instance=RequestContext(request))
    return render(request, 'books/edit.html', {'form': PublisherForm(instance = publisher)})
예제 #4
0
def edit(request, id):
    publisher = get_object_or_404(Publisher, id=id)
    if request.method == 'POST':
        appForm = PublisherForm(request.POST, instance=publisher)
        if appForm.is_valid():
            publisher = appForm.save()
            publisher.save()
            return HttpResponseRedirect(reverse("index"))

    #return render_to_response('books/edit.html', {'form': PublisherForm(instance = publisher)}, context_instance=RequestContext(request))
    return render(request, 'books/edit.html',
                  {'form': PublisherForm(instance=publisher)})