这是我第一次尝试制作Django CMS插件。我准备了以下文件:
cms公司_插件.py
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from cms.models import CMSPlugin
from . import models
class SurveyPluginPublisher(CMSPluginBase):
"""Show Polls entered by Admin."""
cache = False
# model = models.QuickAidPluginModel
module = "Survey"
name = "Awesome Survey v1.0"
render_template = 'survey/_hello.html'
def render(self, context, instance, placeholder):
return context
plugin_pool.register_plugin(SurveyPluginPublisher)
模型.py
^{pr2}$模板文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h2>Hi Survey</h2>
</body>
</html
但当我得到编辑页面选项并尝试添加插件时,它显示了这个屏幕
尝试声明窗体:
在表单.py公司名称:
在模型.py公司名称:
^{pr2}$尝试在您的
SurveyPluginPublisher
中添加一行model = models.SurveyPluginModel
。它需要了解它的模型。在另外,我建议添加
fieldsets
作为属性。它允许设计管理界面。不过,这是没有必要的。在相关问题 更多 >
编程相关推荐