django manytomany multiple upload file

2019-07-20 07:51发布

问题:

Lets say I have a model:

class Image(models.Model):
    title = models.CharField(max_length=50, blank=True)
    description = models.CharField(max_length=50, blank=True)
    image_file = models.FileField(upload_to=get_upload_file_name)

class Thumbnail(models.Model):
    image_files = models.ManyToManyField(Image, related_name="image")

Here image_files of Thumbnail model just give dropdown of image_file of Image model.

But what I want is a form with browse button and when I click it I can select and add multiple images. And later if I want I can change the detail of image

Is there any possibility or way to do this ? I really need this

How can I select and add multiple images from manytomany field and individual images should be saved in Image model. Adding and saving multiple Image model fields from manytomany field of Thumbnail model.

I hope you understand