def update(request, id): if request.method == 'POST': a = FlatPage.objects.get(pk=id) f = FlatpageForm(request.POST, instance=a) f.save() d = FlatPage.objects.all() t = loader.get_template("flatpages_plus/list.html") c = Context({ "data": d, }) # return return HttpResponse(t.render(c)) else: d = FlatPage.objects.get(pk=id) form = FlatpageForm(instance=d) #t = loader.get_template("flatpages_plus/update.html") #c = Context({ # "form":form, # }) # return #return HttpResponse(t.render(c)) return render_to_response( "flatpages_plus/update.html", {"form": form}, RequestContext(request), )
def update(request, id): if request.method == 'POST': a = FlatPage.objects.get(pk=id) f = FlatpageForm(request.POST, instance=a) f.save() d = FlatPage.objects.all() t = loader.get_template("flatpages_plus/list.html") c = Context({ "data":d, }) # return return HttpResponse(t.render(c)) else: d = FlatPage.objects.get(pk=id) form = FlatpageForm(instance=d) #t = loader.get_template("flatpages_plus/update.html") #c = Context({ # "form":form, # }) # return #return HttpResponse(t.render(c)) return render_to_response("flatpages_plus/update.html",{ "form": form }, RequestContext(request), )
def update(request, id): if request.method == 'POST': f = FlatpageForm(request.POST) if f.is_valid(): a = FlatPage.objects.get(pk=id) f = FlatpageForm(request.POST, instance=a) f.save() d = FlatPage.objects.all() paginator = Paginator(d, 2) # Show 2 help on each row page = request.GET.get('page') try: helps = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. helps = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. helps = paginator.page(paginator.num_pages) t = loader.get_template("flatpages_plus/list.html") c = Context({ "data":helps, }) return HttpResponse(t.render(c)) else: return render_to_response("flatpages_plus/add.html",{ "form": f }, RequestContext(request), ) else: d = FlatPage.objects.get(pk=id) form = FlatpageForm(instance=d) #t = loader.get_template("flatpages_plus/update.html") #c = Context({ # "form":form, # }) # return #return HttpResponse(t.render(c)) return render_to_response("flatpages_plus/update.html",{ "form": form }, RequestContext(request), )
def add(request): if request.method == 'POST': post_values = request.POST.copy() f = FlatpageForm(post_values) if f.is_valid(): newflatpage = f.save(commit=False) newflatpage.save(post_values) f.save_m2m() d = FlatPage.objects.all() paginator = Paginator(d, 2) # Show 2 help on each row page = request.GET.get('page') try: helps = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. helps = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. helps = paginator.page(paginator.num_pages) t = loader.get_template("flatpages_plus/list.html") c = Context({ "data":helps, }) return HttpResponse(t.render(c)) else: return render_to_response("flatpages_plus/add.html",{ "form": f }, RequestContext(request), ) else: form = FlatpageForm() print form.errors return render_to_response("flatpages_plus/add.html",{ "form": form }, RequestContext(request), )
def update(request, id): if request.method == 'POST': f = FlatpageForm(request.POST) if f.is_valid(): a = FlatPage.objects.get(pk=id) f = FlatpageForm(request.POST, instance=a) f.save() d = FlatPage.objects.all() paginator = Paginator(d, 2) # Show 2 help on each row page = request.GET.get('page') try: helps = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. helps = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. helps = paginator.page(paginator.num_pages) t = loader.get_template("flatpages_plus/list.html") c = Context({ "data": helps, }) return HttpResponse(t.render(c)) else: return render_to_response( "flatpages_plus/add.html", {"form": f}, RequestContext(request), ) else: d = FlatPage.objects.get(pk=id) form = FlatpageForm(instance=d) #t = loader.get_template("flatpages_plus/update.html") #c = Context({ # "form":form, # }) # return #return HttpResponse(t.render(c)) return render_to_response( "flatpages_plus/update.html", {"form": form}, RequestContext(request), )
def add(request): if request.method == 'POST': post_values = request.POST.copy() f = FlatpageForm(post_values) if f.is_valid(): newflatpage = f.save(commit=False) newflatpage.save(post_values) f.save_m2m() d = FlatPage.objects.all() paginator = Paginator(d, 2) # Show 2 help on each row page = request.GET.get('page') try: helps = paginator.page(page) except PageNotAnInteger: # If page is not an integer, deliver first page. helps = paginator.page(1) except EmptyPage: # If page is out of range (e.g. 9999), deliver last page of results. helps = paginator.page(paginator.num_pages) t = loader.get_template("flatpages_plus/list.html") c = Context({ "data": helps, }) return HttpResponse(t.render(c)) else: return render_to_response( "flatpages_plus/add.html", {"form": f}, RequestContext(request), ) else: form = FlatpageForm() print form.errors return render_to_response( "flatpages_plus/add.html", {"form": form}, RequestContext(request), )