【发布时间】:2020-07-12 02:37:05
【问题描述】:
- 在Wagtail中,如何在Media中添加自定义文件夹并将其同步到数据库中(Example)?
- 注意: Wagtail 的 Collection 功能很好,但是对于我以后将 1000 多个图像/文档放在一个文件夹中管理起来会很尴尬(例如:迁移,...),所以在这个问题中,Collection 函数没什么好说的。
# 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="+",
)
Wagtail 中媒体文件夹的想法:
- 媒体
- 作者
- 图片
- original_images
- 帖子
- 图片
- 原始图像 ...
- 作者
【问题讨论】:
标签: python django django-models wagtail wagtail-admin