I have created a multi image upload form in a Django where the user can upload personal images to his/her profile.
I want to find/create a python function where convert the original image from user to png
and that new convert image update the png_image
field from my model.any idea how to do that? Wow to do this automate for any image upload?
models.py
class MyModel(models.Model):
name = models.TextField()
slug_name = models.SlugField()
user = models.ForeignKey(User, unique=False)
original_image = models.ImageField(upload_to=directory_path)
png_image = models.ImageField(upload_to=directory_path)
views.py
def dataset(request):
uploadimages = UploadImagesForm(request.POST or None, request.FILES or None)
if uploadimages.is_valid():
if request.FILES.get('multipleimages', None) is not None:
images = request.FILES.getlist('multipleimages')
for image in images:
...........