Exemple #1
0
def add_publisher(request):
    if request.method == 'POST':
        form = PublisherForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/add_publisher/')
    else:
            form = PublisherForm()
    return render_to_response('books/add_publisher.html', {'form': form})
Exemple #2
0
def add_publisher(request):
    if request.method == 'POST':
        form = PublisherForm(request.POST)
        if form.is_valid():
            # 从 form_for_model 而来的表单对象包含一个 save() 方法.
            form.save()
            return HttpResponseRedirect('/contact/thanks/')
    else:
        form = PublisherForm()
    return render_to_response('books/add_publisher.html', {'form': form})
Exemple #3
0
def add_publisher(request):
    if request.method == 'POST':
        form = PublisherForm(request.POST)
        if form.is_valid():
            # 从 form_for_model 而来的表单对象包含一个 save() 方法.
            form.save()
            return HttpResponseRedirect('/contact/thanks/')
    else:
        form = PublisherForm()
    return render_to_response('books/add_publisher.html', {'form': form})
Exemple #4
0
def add_publisher(request):
    if request.method == "POST":
        formulario = PublisherForm(request.POST)
        if formulario.is_valid():
            formulario.save()
            return HttpResponseRedirect("/add_publisher/thanks/")
    else :
        formulario = PublisherForm()
    
    return render_to_response("add_publisher.html",{"form":formulario})
def add_publisher(request):
    c = {}
    c.update(csrf(request))
    if request.method == 'POST':
        form = PublisherForm(request.POST)
        if form.is_valid():
            name1 = form.cleaned_data['name']
            website1 = form.cleaned_data['website']
            a = Publisher.objects.filter(name=name1, website=website1)
            if not Publisher.objects.filter(name=name1, website=website1):
                form.save()
                return HttpResponseRedirect('/add_publisher/thanks/')
        else:
            form = PublisherForm()
    else:
        form = PublisherForm()

    c['form'] = form
    return render_to_response('books/add_publisher.html', c)