我尝试将图像基本上传到Django的图库,但是我不太确定如何将多个文件作为独立应用程序上传。如何创建图库表单,以便可以添加和删除图像?
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)
答案 0 :(得分:1)