简体   繁体   中英

How to upload multiple images

I'm trying to implement basic uploading of images to a gallery in Django, however I'm not quite sure of how to perform multiple files upload as a standalone app. How can I create a gallery form whereby images can be added and deleted from?

models.py

from django.db import models
from PIL import Image


class Gallery(models.Model):
    name = models.CharField(max_length=20)


class Image(models.Model):
    title       = models.CharField(max_length=60, blank=True, null=True)
    description = models.TextField(blank=True, null=True)
    image       = models.ImageField(upload_to='testimg/profile_images', blank=True, null=True)
    gallery     = models.ForeignKey(Gallery, related_name="images", blank=True)
    hidden      = models.BooleanField()
    created     = models.DateTimeField(auto_now_add=True)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM