def create(request): data = {} if request.method == "POST": form = ProtocolForm(request.POST) if form.is_valid(): protocol = form.save() return redirect(reverse("manage_protocols")) else: form = ProtocolForm() data["form"] = form return render(request, "protocols/create.html", data)
def create(request): data = {} if request.method == 'POST': form = ProtocolForm(request.POST) if form.is_valid(): protocol = form.save() return redirect(reverse('manage_protocols')) else: form = ProtocolForm() data['form'] = form return render(request, 'protocols/create.html', data)
def update(request, protocol): data = {} protocol = get_object_or_404(db.Protocol, label=protocol) if request.method == "POST": form = ProtocolForm(request.POST, instance=protocol) if form.is_valid(): protocol = form.save() return redirect(reverse("manage_protocols")) else: form = ProtocolForm(instance=protocol) data["form"] = form data["protocol"] = protocol return render(request, "protocols/update.html", data)
def update(request, protocol): data = {} protocol = get_object_or_404(db.Protocol, label=protocol) if request.method == 'POST': form = ProtocolForm(request.POST, instance=protocol) if form.is_valid(): protocol = form.save() return redirect(reverse('manage_protocols')) else: form = ProtocolForm(instance=protocol) data['form'] = form data['protocol'] = protocol return render(request, 'protocols/update.html', data)