python - Delete items from ListView in Django 1.5 -
i have listview , deleteview
class mydeleteview(deleteview): success_url = reverse('list')
i want option delete items in listview. know how if accept confirmation page in deleteview, don't want no template in deleteview. want delete item , send user back.
i guess should post parameters, should html like? guess it's like:
<form method="post" action="/delete/"> <ul> <li>item1 (<input type="submit" value="delete" />)</li> <li>item2 (<input type="submit" value="delete" />)</li> <li>item3 (<input type="submit" value="delete" />)</li> </ul> </form>
can lead me in right direction? thank you.
since don't want confirmation, can override method in deleteview , use links:
class mydeleteview(deleteview): success_url = reverse('list') def get(self, *a, **kw): return self.delete(*a, **kw)
<ul> {% item in object_list %} <li>item1 (<a href="{% url 'mydelete' pk=item.pk %}">delete</a>)</li> {% endif %} </ul>
Comments
Post a Comment