我不知道我做错了什么,因为我遵循了文档。我认为这是一些小事。这是场景:
该插件是一个文本幻灯片插件。它允许管理员添加像幻灯片一样循环的文本。
型号如下:
class TextSlideshow(CMSPlugin):
label = models.CharField(max_length=128)
interval = models.IntegerField(
default=5000,
help_text=_('milliseconds between slides. (1000 equals 1 second)'))
def copy_relations(self, oldinstance):
for slide in oldinstance.text_slides.all():
slide.pk = None
slide.id = None
slide.text_slide_show = self
slide.save()
def __unicode__(self):
return self.label
class TextSlide(CMSPlugin):
text_slide_show = models.ForeignKey(TextSlideshow, related_name="text_slides")
display_value = models.CharField(max_length=128)
index = models.IntegerField(verbose_name=_("Display order"))
内联是:
class TextSlideInline(admin.StackedInline):
model = TextSlide
fk_name = 'text_slide_show'
该插件是:
class TextSlideshowPlugin(CMSPluginBase):
model = TextSlideshow
name = _("Text Slideshow")
render_template = "text_slideshow.html"
inlines = [TextSlideInline,]
module = _("Slideshow")
def __init__(self, model=None, admin_site=None):
super(TextSlideshowPlugin, self).__init__(model=model,
admin_site=admin_site)
for inline in self.inlines:
inline.placeholder = self.placeholder
inline.page = self.page
def render(self, context, instance, placeholder):
slides = instance.text_slides.all().order_by('index')
context.update({
'model': instance,
'placeholder': placeholder,
'slides': slides
})
return context
plugin_pool.register_plugin(TextSlideshowPlugin)
该插件可以正常工作并且可以完美运行,但是当管理员用户添加文本幻灯片时,如下所示:
当我跑
./manage.py cms list plugins
我得到这个结果:
==== Plugin report ====
There are 2 plugin types in your database
ERROR : not installed
instance(s): 2
TextSlideshowPlugin
model : cmsslideshow.models.TextSlideshow
instance(s): 1
只要我不跑
./manage.py cms delete_orphaned_plugins
我的幻灯片将保持机智并且可以正常工作。
文本幻灯片本身很好,它只是孤立的内联元素。
请帮忙。