Django 和 FeinCMS:在其他正常模型中使用媒体库的方法?

发布于 2024-09-15 16:09:09 字数 333 浏览 6 评论 0原文

我在一个项目中使用 Django 和 FeinCMS。我目前正在为网站上的所有页面使用 FeinCMS。但我还有另一个单独的模型,可以为网站处理非常简单的库存。该库存模型具有常用字段(名称、描述等),但我也希望它有照片。

因为 FeinCMS 已经有一个媒体库,所以我想在技术上使用它来将照片与我的库存模型一起使用。我通常可以做一个照片模型和ManyToManyField,但我很好奇我是否可以使用FeinCMS 媒体库做ManyToManyField?

我知道使用 FeinCMS,您可以在任何其他模型上使用项目编辑器,但我不确定这是正确的方法。如果这是做到这一点的唯一方法,那么就必须如此。

非常感谢

I'm using Django and FeinCMS on a project. I'm currently using FeinCMS for all the pages on the site. But I also have another separate model that handles very simple stock for the site too. This stock model has the usual fields (name, description, etc) but I also want it to have photos.

Because FeinCMS has a media library already, I would like to technically use that to have the photos with my stock model. I could just normally do a Photo model and ManyToManyField that, but I'm curious to know if I can ManyToManyField with the FeinCMS media library?

I know with FeinCMS you can use the item editor on any other model, but I'm not sure that's the right way to go about it. If it's the only way to do this, then that will have to be it.

Many thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

回忆躺在深渊里 2024-09-22 16:09:09

当然,没有什么可以阻止您向 MediaFile 模型中添加外键或多对多字段到您自己的模型之一。请注意,您将很难将媒体文件限制为仅图像。也许 limit_choices_to 会有所帮助。

Sure -- there's nothing stopping you from adding a ForeignKey or a ManyToManyField to the MediaFile model to one of your own models. Note that you'll have a hard time limiting the media files to only images. Maybe limit_choices_to will help though.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文