1
I am trying to create a dialog to remove a client in Django (I created the dialog with Materialize), but when trying to remove it does not execute the view function inside the html page. Could someone help?
delete
        <!-- Modal Structure -->
        <div id="modal1" class="modal">
            <div class="modal-content">
                <h4>Deseja remover o Cliente {{ Cliente.nome_cliente }}?</h4>
            </div>
            <div class="modal-footer">
                <form method="post">
                    {% csrf_token %}
                    <button name="remover_cliente" type="submit" class="modal-close btn light-blue lighten">Remover</button>
                    <a href="{% url 'listar_cliente' %}" class="modal-close btn light-blue lighten">Voltar</a>
                </form>
            </div>
        </div>
Views.py
@login_required
def remover_cliente(request, pk):
    cliente = Cliente.objects.get(pk=pk)
    if request.method == "POST":
        cliente.delete()
        return redirect('listar_cliente')
    return render(request, {'cliente': cliente})
						
I thought about it but I didn’t know if it was right. Now I know how to do it, thank you.
– João Gabriel Maciel