我应该将 Django-CMS 插件的媒体文件放在哪里?

发布于 2024-11-02 18:02:35 字数 505 浏览 5 评论 0原文

我即将为我的 Django CMS 插件编写 setup.py,但我不知道应该将图标放在哪里。

在我看来,根据您应该放置模板的位置来判断,以下内容是最直观的:

/media
  /cms
    /images
      /plugins
        my_image.png
cms_plugin.py

cms_plugin.py 中,我有以下方法:

def icon_src(self, instance):
    print settings.CMS_MEDIA_URL
    return settings.CMS_MEDIA_URL + u"images/plugins/my_image.png"

如果我重新执行,则上述方法有效使用 link.png 图像,但我正在寻找可以与我的插件捆绑在同一文件夹中的东西。

我缺少什么?

I'm about to write setup.py for my Django CMS plugin, but I can't figure out where I'm supposed to put the icon.

It seemed to me like the following would've been the most intuitive, judging by where you are supposed to place templates:

/media
  /cms
    /images
      /plugins
        my_image.png
cms_plugin.py

In cms_plugin.py I have the following method:

def icon_src(self, instance):
    print settings.CMS_MEDIA_URL
    return settings.CMS_MEDIA_URL + u"images/plugins/my_image.png"

The above works if I instead re-use the link.png image, but I'm looking for something I can bundle in the same folder as my plugin.

What am I missing?

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

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

发布评论

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

评论(1

落花浅忆 2024-11-09 18:02:35

我不确定这是否是一个约定,但我注意到有一些人将其放入

myproject/media/myproject/images

或类似的约定中。

django-cms 扩展和插件

百日草

https://github.com/Fantomas42/django-blog-zinnia/tree/master/zinnia/media/zinnia/img

jplayer

https://github.com/ojii/django-cms-jplayer/tree/master/jplayer/media/jplayer

I'm not sure if this is a convention or not but i've noticed a few put it in

myproject/media/myproject/images

or some such equivalent.

some examples from django-cms extensions and plugins

Zinnia

https://github.com/Fantomas42/django-blog-zinnia/tree/master/zinnia/media/zinnia/img

jplayer

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