4

我已经检查了许多上传者的 django 图片字段。但我无法获得在 Django 中进行多张图片上传的简单明了的方法。

我的要求是

Class Foo(models.Model):
       images = SomeImageField(upload_to = "/path/")

这应该允许我上传多张图片。现在django-photologue 允许 Gallery 上传,但这只是 zip 格式。我想要类似的东西。有没有这样的应用程序可用?

4

1 回答 1

5

django-filer将允许您通过单独的界面(不是通过模型字段,而是通过 django 管理员)上传多个图像,但您只能在每个图像字段中选择一个上传的图像。你需要做的是实现一个django admin StackedInline或类似的东西

# models.py
from django.db import models
from filer.fields.imagefields import FilerImageField

class MyObject(models.Model):
    name = models.CharField(...)

class Image(models.Model):
    image_file = FilerImageField()
    obj = models.ForeignKey(MyObject, ...)

# admin.py
from django.contrib import admin
from models import Image, MyObject

class ImageInline(admin.StackedInline):
    model = Image

class MyObjectAdmin(admin.ModelAdmin):
    inlines = [ImageInline, ]

...

现在,您将能够通过管理员轻松地将多个图像附加到对象的单个实例。

我不知道任何允许单个字段管理多个图像的应用程序。

于 2013-09-27T08:28:22.890 回答