D
D
devalone2017-05-10 23:07:51
Django
devalone, 2017-05-10 23:07:51

How to do multiple file upload from admin panel?

The following models are available:

class Category(models.Model):
 ...

class CategoryPhoto(models.Model):
    category = models.ForeignKey(Category, on_delete=models.CASCADE, verbose_name='фото')
    image = models.ImageField(upload_to='category_photos', verbose_name='фото')
    name = models.CharField(max_length=50, blank=True, verbose_name='название')
...

Connected in admin panel like this:
class CategoryPhotoInline(admin.StackedInline):
    model = CategoryPhoto
    extra = 0
...

class CategoryAdmin(admin.ModelAdmin):
...
    inlines = [CategoryPhotoInline]

It turns out here is such an interface:
7e51f15ffef64c6888bae62496064ebc.png
But uploading files one at a time is not convenient. Is there a way to teach django to load all files from a directory without much shamanism, so as not to manually select each one? I don't even dream about ajax with loading progress...

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
devalone, 2017-05-11
@devalone

In general, I decided this way: ishalyapin.ru/%D0%BC%D1%83%D0%BB%D1%8C%D1%82%D0%B8...
Not very convenient, since the download is on a separate page, but it works not bad

S
Stalker_RED, 2017-05-11
@Stalker_RED

Google "django multiupload" and choose one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question