我正在阅读扩展CMS。
我在理解一些细节方面有一些问题:
我需要创建一个插件类,例如 PollPlugin
.
class PollPlugin(CMSPluginBase):
model = PollPluginModel # Model where data about this plugin is saved
name = _("Poll Plugin") # Name of the plugin
render_template = "polls/plugin.html" # template to render the plugin with
def render(self, context, instance, placeholder):
context.update({'instance':instance})
return context
plugin_pool.register_plugin(PollPlugin) # register the plugin
我的问题:
- 在这种情况下
instance
是什么? - 这两个插件类的目标是什么?
PollPluginModel
和PollPlugin
. Apphook
和Plugin
之间的区别
任何答案都值得赞赏
Django-CMS插件可能有点棘手。
在这种情况下,instance
将是PollPlugin
的实例。
PollPlugin
充当"连接"模型,将PollPluginModel
的一个或多个实例与插件实例(PollPlugin(相关联,然后将其分配给页面上的占位符。
"apphook"是一个回调,它告诉Django-CMS它需要将视图的处理移交给应用程序模块中其他用户指定的URL模式。
"插件"是可以分配给占位符的模型。