'Image Update is not happening in Django

I had used code to update the image in Django, but it doesn't resulted as expected.

    if request.method == "POST":
        data = ImageModel.objects.get(pk=id)
        pid = customer.objects.get(pk=id)
        fm = CustomerRegisteration(request.POST, request.FILES, instance=pid)
        if fm.is_valid():
            data.image_document.delete()
            fm.save()

This code doesn't work



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source