zan
zan

Reputation: 594

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)

Upvotes: 0

Views: 1090

Answers (1)

Jeff Gu Kang
Jeff Gu Kang

Reputation: 4879

It will help you to make upload multiple files.

Formsets: https://docs.djangoproject.com/en/1.7/topics/forms/formsets/

Form wizard: https://docs.djangoproject.com/en/1.7/ref/contrib/formtools/form-wizard/

Upvotes: 1

Related Questions