(sorry for my bad english)
I need to delete an object, but directly from a list of the objects that y have in my template.
I have a work orders, that have spare
here in fa fa-thrash pass the id and the URL as I did it:-
{% if spare_parts %}
{% trans "Spare Part" %}
{% trans "Price" %}
{% trans "Delete" %}
{% for part in spare_parts %}
{{ part.spare_part }}
{% if part.price %}
$ {{ part.price }}
{% else %}
{% endif %}
{% endfor %}
{% else %}
NO HAY REPUESTOS ASENTADOS AÚN
{% endif %}
ur url would be sonething like that:
url(r'^delete/(?P[0-9]+)/$', view.function, name='delete_view'),
in ur view:
def function(request,part_id =None):
object = YourModel.objects.get(id=part_id)
object.delete()
return render(request,'ur template where you want to redirect')