1
  • In Wagtail, How to add custom folder in Media and sync it into the database (Example) ?
  • NOTE: The Wagtail's Collection function is good, but for more than 1000 images/documents into a single folder will be pretty awkward to manage for I in the future (Ex: migration,...), so there is nothing to mention about Collection function in this question.
# If in Django (models.py) works:
class post(models.Model):
    img = models.ImageField(upload_to='posts')
# So how in Wagtail (models.py) works:
class Posts(models.Model):
    img = models.ForeignKey(
        "wagtailimages.Image",
         upload_to='posts', # How to add this line correctly ?
        on_delete=models.SET_NULL,
        null=True,
        blank=False,
        related_name="+",
    )

Idea for Media Folder in Wagtail:

  • Media
    • authors
      • images
      • original_images
    • posts
      • images
      • original_images ...
VQH-cmd
  • 51
  • 2
  • 6

1 Answers1

0

If you want specific folders for specific models, you can set a specific folder by customizing the upload_to attribute in the model. Otherwise, the only option I know is to create collections.

cnk
  • 981
  • 1
  • 5
  • 9