1
I have a file views.py which has the following method:
def alterar(request, pk):
    cliente = get_object_or_404(Cliente, pk=pk)    
    if request.method == 'POST':
        form = ClienteForm(request.POST, instance = cliente)
            if form.is_valid():
                cliente = form.save(commit=False)
                cliente.save()
                cliente_listar = Cliente.objects.all()
                return render(request, 'cliente/listar.html', {'cliente' : cliente_listar}) 
    else:
        form = ClienteForm(instance=cliente)
        return render(request, 'cliente/cadastro.html', {'form' : form})
My problem is in render() of POST, because back to url of list you still get the following url: http://127.0.0.1:8000/cliente/alterar/5/, but with the page of list, the right in my view would have to be: http://127.0.0.1:8000/cliente/listar/.
In some researches I found the redirect() but equal to url is in that format: http://127.0.0.1:8000/cliente/alterar/5/cliente/listar.html in which you end up making a mistake.
I’m using Python 3.5 and Django 1.10