コード例 #1
0
def author_add(request):
    if request.method == 'POST':
        form = AuthorForm(request.POST)
        if form.is_valid():
            form.save()
            return render_to_response('common/success.html')
    else:
        form = AuthorForm()

    variables = RequestContext(request, {'form': form})
    return render_to_response('crud/author/author_add.html', variables)
コード例 #2
0
ファイル: views.py プロジェクト: sholokhova/gecko2
def author_add(request):
    if request.method == "POST":
        form = AuthorForm(request.POST)
        if form.is_valid():
            form.save()
            return render_to_response("common/success.html")
    else:
        form = AuthorForm()

    variables = RequestContext(request, {"form": form})
    return render_to_response("crud/author/author_add.html", variables)
コード例 #3
0
ファイル: views.py プロジェクト: A-Kulikov/python2012
def author_add(request):
    if request.method == 'POST':
        form = AuthorForm(request.POST)
        if form.is_valid():
            form.save()
            return render_to_response('common/success.html')
    else:
        form = AuthorForm()

    variables = RequestContext(request, {
        'form': form
    })
    return render_to_response('crud/author/author_add.html', variables)
コード例 #4
0
def author_edit(request, id):
    author = Author.objects.get(pk=id)
    if request.method == "POST":
        form = AuthorForm(request.POST, instance=author)
        if form.is_valid():
            form.save()
            return render_to_response('common/success.html')
    else:
        form = AuthorForm(instance=author)

    variables = RequestContext(request, {'form': form})

    return render_to_response("crud/author/author_edit.html", variables)
コード例 #5
0
ファイル: views.py プロジェクト: sholokhova/gecko2
def author_edit(request, id):
    author = Author.objects.get(pk=id)
    if request.method == "POST":
        form = AuthorForm(request.POST, instance=author)
        if form.is_valid():
            form.save()
            return render_to_response("common/success.html")
    else:
        form = AuthorForm(instance=author)

    variables = RequestContext(request, {"form": form})

    return render_to_response("crud/author/author_edit.html", variables)
コード例 #6
0
ファイル: views.py プロジェクト: gladson/Django-Examples
def author_manager(request, author):
    BookInlineFormSet = inlineformset_factory(Author, Book, extra=1,
                                              formfield_callback=add_category)

    form = AuthorForm(request.POST or None, instance=author)
    formset = BookInlineFormSet(request.POST or None, instance=author)

    if form.is_valid() and formset.is_valid():
        form.save()
        formset.save()
        return HttpResponseRedirect('/inlines/')

    return render_to_response("manage_authors.html",
        {"formset": formset,
        "form": form},
        RequestContext(request))
コード例 #7
0
def author_manager(request, author):
    BookInlineFormSet = inlineformset_factory(Author,
                                              Book,
                                              extra=1,
                                              formfield_callback=add_category)

    form = AuthorForm(request.POST or None, instance=author)
    formset = BookInlineFormSet(request.POST or None, instance=author)

    if form.is_valid() and formset.is_valid():
        form.save()
        formset.save()
        return HttpResponseRedirect('/inlines/')

    return render_to_response("manage_authors.html", {
        "formset": formset,
        "form": form
    }, RequestContext(request))