I don't know what I am doing wrong as I have followed the documentation. I'm thinking it is some little thing. Here is the scenario:
The plugin is a Text Slideshow plugin. It allows the admin the ability to add text that will cycle like a slideshow.
The models are as follows:
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"))
The inline is:
class TextSlideInline(admin.StackedInline):
model = TextSlide
fk_name = 'text_slide_show'
The plugin is:
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)
The plugin works and will run flawless, but when the admin user adds text slides like so:
When I run
./manage.py cms list plugins
I get this result:
==== Plugin report ====
There are 2 plugin types in your database
ERROR : not installed
instance(s): 2
TextSlideshowPlugin
model : cmsslideshow.models.TextSlideshow
instance(s): 1
As long as i don't run
./manage.py cms delete_orphaned_plugins
my slideshow will stay in tact and will work fine.
The text slideshow itself is fine, it's just the inline'd elements which are orphaned.
Please help.
After reviewing my code with a microscope several times while re-reading the documentation and many examples, I found my issue.
The issue is the child model should inherit from models.Model, not CMSPlugin
change:
to: