コード例 #1
0
def index(request):
    if request.method == "POST":
        form = FormularioForm(request.POST)
        if form.is_valid():
            form.save()
            return redirect('editar_reg_forms.views.listar')
    else:
        form = FormularioForm()
        
    return render(request, 'editar_reg_forms/index.html', {'form': form})
コード例 #2
0
def editar(request, pk):
    formulario = get_object_or_404(Formulario, pk=pk)
    if request.method == "POST":
        form = FormularioForm(request.POST, instance=formulario)
        if form.is_valid():
            formulario.save()
            return redirect('editar_reg_forms.views.listar') 
        
    else:
        form = FormularioForm(instance=formulario)
        
    return render(request, 'editar_reg_forms/index.html', {'form': form})