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)
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)
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)
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)
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)
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))
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))