I want to know how to add a delete button in my form for deleting an image.
The project is a simple \"Pics viewer\", the index shows all the images that are stored but I
urls.py
[.........]
url(
r'^delete-image/(?P\d+)/$',
'delete_image',
name="delete_image"
),
[.........]
views.py
def delete_image(request, id):
image = Image.objects.get(pk=id).delete()
return HttpResponseRedirect(reverse('app_name:url_name'))
template
{% for image in images_list %}
-
Delete
{% endfor %}