Exemple #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()})
Exemple #2
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()})
Exemple #3
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)})
Exemple #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)})