Error DeleteView


Hi, I have a problem with my DeleteView in Django 1.8, I get this error:


TemplateDoesNotExist at /eliminar_tipo_almacen/38/appkardex/tipo_almacen_confirm_delete.html

from django.views.generic import ListView, UpdateView, DeleteView

class EliminarTipoAlmacen(DeleteView):
    model = Tipo_almacen
    success_url = reverse_lazy('lista_tipo_almacen')

url(r'^eliminar_tipo_almacen/(?P<pk>\d+)/$', views.EliminarTipoAlmacen.as_view(), name='eliminar_tipo_almacen'


<table class="table">

    {% for data in lista_tipo_almacen %}
      <td>{{ data.descripcion }}</td>
       <a href="{% url 'editar_tipo_almacen' %}"><span class="glyphicon glyphicon-file">Editar </span></a>
       <a href="{% url 'eliminar_tipo_almacen' %}"><span class="glyphicon glyphicon-trash">Borrar </span></a>

   {% endfor %}


{% extends "main.html" %}

{% block contenido %}
  <form action="" method="post">{% csrf_token %}
      <p>Quieres eliminar "{{ object }}"</p>
      <input type="submit" value="Confirmar" />

{% endblock %}

Waiting for your collaboration

asked by Andres Vilca 27.01.2016 в 02:17

2 answers


you need to pass the name of the template in your DeleteView class

template_name = "eliminartipoalmacen.html"

create that template that serves to confirm the elimination

answered by 10.03.2016 в 00:50

In the code fragments you do not say how lista_tipo_almacen is resolved. Apparently you intend to call a template that is named (although you do not call the template, but in plain sight) , so you should have a path in your file that resolves that call .

from django.views.generic import TemplateView
url(r'^lista/$', TemplateView.as_view(template_name='lista_tipo_almacen.html')),

Actually, you are calling the function that returns the list type store, then this is the way you should call the function:

url(r'^lista/$', 'lista', name='lista_tipo_almacen'),

Or if it's a class-based view, it would be something like that

from .views import Lista:
url(r'^lista/$', Lista.as_view(), name='lista_tipo_almacen'),

In any case, the reverse_lazy function resolves a defined route in your search patterns, does not call a template directly.

answered by 28.01.2016 в 05:23