def editar_agendamento(request,id): agendamentos = Agendamento.objects.get(id=id) newcadastro = 'N' if request.method == 'POST': agendamento_form = AgendamentoForm(request.POST, instance=agendamentos) if agendamento_form.is_valid: agendamento_form.save() return redirect(reverse('core:consultaagendamento')) else: print(agendamento_form.errors) else: agendamento_form = AgendamentoForm(instance=agendamentos) return render(request, 'form_agendamento.html',{'agendamento_form':agendamento_form, 'newcadastro': newcadastro})
def form_agendamento(request): newcadastro = 'S' if request.method == 'POST': agendamento_form = AgendamentoForm(request.POST, request.FILES) if agendamento_form.is_valid(): agendamento_form.save() agendamento_form = AgendamentoForm() return render(request, 'form_agendamento.html', {'agendamento_form': agendamento_form, 'newcadastro': newcadastro}) #return redirect('/') else: agendamento_form = AgendamentoForm() return render(request, 'form_agendamento.html', {'agendamento_form': agendamento_form, 'newcadastro': newcadastro})