def new_charity(request): if request.method == "POST": form1 = CharityForm(request.POST) if form1.is_valid(): if form1.save(): return redirect("/charities") else: form1 = CharityForm() data = {'form1': form1} return render(request, "charities/new_charity.html", data)
def edit_charity(request, charity_id): charity = Charity.objects.get(id=charity_id) if request.method == "POST": form1 = CharityForm(request.POST, instance=charity) if form1.is_valid(): if form1.save(): return redirect("/charities/{}".format(charity_id)) else: form1 = CharityForm(instance=charity) data = {"charity": charity, "form1": form1} return render(request, "charities/edit_charity.html", data)
def fbedit_charity(request, fbcharity_id): charity = Charity.objects.get(id=fbcharity_id) if request.method == "POST": form2 = CharityForm(request.POST, instance=charity) if form2.is_valid(): if form2.save(): return redirect("fbcharities") else: form2 = CharityForm(instance=charity) data = {"charity": charity, "form2": form2} return render(request, "fbcharities/fbedit_charity.html", data)
def new_charity(request): if request.method == "POST": form0 = CharityForm(request.POST) if form0.is_valid(): charity = form0.save(commit=False) charity.user = request.user charity.save() return redirect("/charities") else: form0 = CharityForm() data = {"form0": form0} return render(request, "charities/new_charity.html", data)
def fbnew_charity(request): if request.method == "POST": form1 = CharityForm(request.POST) if form1.is_valid(): charity = form1.save(commit=False) charity.user = request.user charity.save() return redirect("/fbcharities") else: form1 = CharityForm() data = {'form1': form1} return render(request, "fbcharities/fbnew_charity.html", data)
def new_charity(request): if request.method == "POST": form0 = CharityForm(request.POST) if form0.is_valid(): charity = form0.save(commit=False) charity.user = request.user charity.save() return redirect("/charities") else: form0 = CharityForm() data = {'form0': form0} return render(request, "charities/new_charity.html", data)