A
A
Alexander Bondarenko2019-11-23 16:16:31
Django
Alexander Bondarenko, 2019-11-23 16:16:31

Is it possible to store a set of images in a database?

Is it possible to store a set of images in a Django database, such as a list, so that they can then be retrieved through a loop?
If yes, please tell me how to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2019-11-26
@bond_1013

Write an image model associated with the main one. In addition to this model ImageField, you can add a name, description, sorting index, etc. As a rule, this additional data is always needed.

class Photoalbum(models.Model):
    ...

class PhotoalbumImage(models.Model):
    photoalbum = models.ForeignKey(Photoalbum, ...)
    image = models.ImageField('изображение', ...)
    ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question