0
我试图在Django-CMS文档(http://docs.django-cms.org/en/2.3.5/extending_cms/custom_plugins.html)中复制2.4中的示例。但是,每当我在cms_plugins.py下指定class HelloPlugin
时,管理中的整个CMS部分都会消失。任何想法是什么造成这个?当我指定模型时,管理员的CMS部分消失
models.py
from django.db import models
class MyModel(models.Model):
title = models.CharField(max_length=50, null=True, blank=True)
def __unicode__(self):
return self.title
from cms.models.pluginmodel import CMSPlugin
class HelloPlugin(CMSPlugin):
ad = models.ForeignKey('core.MyModel', related_name='plugins')
def __unicode__(self):
return self.ad.title
cms_plugins.py
class HelloPlugin(CMSPluginBase):
model = MyModel
name = _("MyModel Plugin")
render_template = "myplugin.html"
def render(self, context, instance, placeholder):
context['instance'] = instance
return context
plugin_pool.register_plugin(HelloPlugin)