0
Good evening, guys. This is my first post on the forum and I’m also a little layman on Jango. I’m developing a project that involves a model called Art and in one of the views I need to update data. I did the whole part of the form and it arrives in the template, but when I click on the button to save the changes I am presented with the error Arte matching query does not exist.
Below follows the code of the view. If you need any more, I am available. Thanks in advance.
def editarte(request):
id_arte = request.GET.get("id")
arte = Arte.objects.get(id = id_arte)
formEditArte = EditArteModelForm(request.POST or None, instance = arte)
if request.method == 'POST':
if formEditArte.is_valid():
arte.save()
return redirect('/editarte')
formEditArte = EditArteModelForm()
context = {
'formEditArte' : formEditArte,
'arte': arte
}
return render(request, 'editarte.html', context)
Cleverton, also displays the HTML of the form and the
urls.py
so I can take a look at how it’s being accessed– mazulo