0
I have an application and when I send the data in the form to be updated it works ( the data are shown in the form) but when I click save the update it repeats the initial data and saves nothing.
Follows code :
view py.
def Atualizar(request, id):
atualizar = get_object_or_404(Local, id=id)
local = FormularioLocal(instance=atualizar)
if local.is_valid():
local_banco = local.save(commit=False)
local_banco.save()
return redirect("gerenciar_local")
form = {}
form['local'] = local
return render(request, "local/atualizar.html", form)
And the template to render the form with the data passed :
<h1> Atualizar <h1>
<form method="post">
{% csrf_token %}
{{ local.as_p }}
<button type="submit">Salvar</button>
</form>
How do I save upgrades ?
Yes, I’m using Modelform. This answer you gave worked.
– Beto