【发布时间】:2013-04-05 07:49:39
【问题描述】:
运行 django-cms 2.4.0-RC1、django 1.5.1 和 python 2.7 的全新安装。我正在尝试使用单个字段创建一个非常简单的自定义插件。该插件在管理员中注册并且工作正常。它成功存储在数据库中。它只是没有在我的模板中呈现。
我已经验证了 render_template 路径并尝试使用硬编码的绝对路径。我已经尝试覆盖 CMSSelectDegreeLevelPlugin 中的渲染方法。
我是否忽略了一些明显的东西?我之前做过非常相似的插件(在不同版本的 django-cms 中)并且没有遇到任何问题。
models.py:
from cms.models.pluginmodel import CMSPlugin
from django.db import models
class SelectDegreeLevel(CMSPlugin):
degree_level = models.CharField('Degree Level', max_length=50)
cms-plugins.py
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from django.utils.translation import gettext_lazy as _
from models import SelectDegreeLevel
class CMSSelectDegreeLevelPlugin(CMSPluginBase):
model = SelectDegreeLevel
name = _('Degree Level')
render_template = "cms/plugins/select_degree_level.html"
plugin_pool.register_plugin(CMSSelectDegreeLevelPlugin)
select_degree_level.html
<h1>static text test {{ instance.degree_level }}</h1>
【问题讨论】:
-
你让它工作了吗...?
-
我在自己的全新 Django cms 安装中构建了这个。它有效。你能在你项目的地方展示吗?
-
你已经尝试过稳定的 2.4 版本的 Django Cms 了吗?
标签: django-cms