The view stock.views.eliminar_tipomaterial didn't return an HttpResponse object. It returned None instead
I am doing a CRUD with Django 5.1 I want to delete the data when I press on the delete button it stays in the same but it shows this error:
views.py
def eliminar_tipomaterial(request, tipomaterial_id):
tipomaterial = get_object_or_404(TipoMaterial, pk=tipomaterial_id)
if request.method == 'POST':
tipomaterial.delete()
return redirect('tipomaterial.html')
Tipomaterial.html
<main class="container">
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr style="text-align: center;">
<th scope="col">Nombre del material</th>
<th scope="col" colspan="2">Acciones</th>
</tr>
</thead>
<tbody class="table-group-divider">
{% for datos in tipomaterial %}
<tr>
<td>
<li class="list-group-item" href="{% url 'detalle_tipomaterial' datos.id %}">
<strong>{{datos.nombre}}</strong>
</li>
</td>
<td>
<a class="btn btn-primary" href="{% url 'detalle_tipomaterial' datos.id %}" role="button">
<i class="bi bi-pencil-fill">
Editar
</i>
</a>
<a class="btn btn-danger" href="{% url 'eliminar_tipomaterial' datos.id %}" role="button">
<i class="bi bi-trash3-fill">
Eliminar
</i>
</a>
</td>
</tr>
{% endfor%}
</tbody>
</table>
</div>
</main>