Q:

Deleting individual related files - Django

I have a django modelformset which does the following:
Add page

Add model instance for 'product' 
Model related (ForeignKey) to
'product' for adding multiple  pictures to the product instance.

Edit Page

The formset is also on an editing page, it is pre-populated with the 'product' instance and its related images.

Here's the problem, when I upload multiple images to a product, I want to be able to delete selected images from the edit page (keep the rest).
How can I pass the individual image - its location in the database, and its location on the filesystem, to some kind of delete method? In an ideal world I would like achieve this by some kind of AJAX method, but where can I start?
View for editing...
def EditProduct(request, pk):
    instance = get_object_or_404(Product, id=pk)
    ImageFormSet = modelformset_factory(ProductImage,
                                        form=ImageForm, extra=4)

    if request.method == 'POST':
        product_form = AddEditProductForm(request.POST, instance=instance)
        formset = ImageFormSet(request.POST, request.FILES,
                        queryset=ProductImage.objects.none())

        if product_form.is_valid() and formset.is_valid():

            product = product_form.save()

            images = formset.save(commit=False)
            for image in images:
                image.product = product
                image.save()
            return HttpResponseRedirect('/product/')

        else:
            print (product_form.errors, formset.errors)

    else:
        product_form = AddEditProductForm(instance=instance)
        formset = ImageFormSet(queryset=ProductImage.objects.all())

    return render(request, 'product/edit.html',
                  {'product_form': product_form, 'formset': formset},
                  context_instance=RequestContext(request))

A minor thing - How can I actually display, in the template, the images that are already uploaded to the product? Currently the images just display as pre-populated extra instances of the formset (url to image file).
template for editing...
<form action="" method="POST" enctype="multipart/form-data">
{% csrf_token %}
    <table> 
            <p> {{ product_form.as_ul }}</p>

                <p> current images </p>     

                {% for product in product.images.all %}
                <img src="{{ product.image.url }}" alt="...">
                {% endfor %}
                <br> <p> break </p>

            {{ formset.management_form }}
            {% for form in formset %}
            {{ form }}
            {% endfor %}
    </table>

    <input type="submit" value="Confirm Changes">

A:

After a long search I found a way to delete individual images by using a custom function. 
If you want to display the images related to a product, there are a couple of ways I found: one way is to modify the FileField widget if you want to display the images in the form...
What I did instead was remove the uploaded images that prepopulated the form by changing the second queryset toqueryset=ProductImage.objects.none()), then I added pictures = ProductImage.objects.filter(product_id = pk) to the view  and then looped through them in the template. 
Hopefully this helps somebody.

