The problem here has not much to do with your schema specifically but with how django handles OneToOne
relationships.
When you subclass CMSPlugin
, django creates an implicit OneToOne
relationship from your model to the CMSPlugin
and vice versa.
This being the case, imagine the following scenario:
I have a plugin called Title
:
class Title(CMSPlugin):
text = models.CharField(max_length=200)
the model above would have access to the CMSPlugin
table via a cmsplugin_ptr
attribute and a CMSPlugin
instance would have access to it's Title
via the automatically created attribute "title" <-- classname.lower()
So given the example above, if now I want another plugin called Video
class VideoPlugin(CMSPlugin):
title = models.CharField(max_length=200)
here's the problem, when you save the video plugin, the title
field clashes with the automatically generated title attribute from the previous plugin thus throwing a
Cannot assign "''": "VideoPlugin.title" must be a "Title" instance
.
This is mentioned very lightly in the docs.
So all you have to do in your case is rename the link
field to something else.
I usually name the fields of my plugins with their classname, so in your case I would end up with
class ImageText(CMSPlugin):
image_text_image = FilerImageField(related_name="image0")
image_text_link = models.CharField(max_length=255, blank=True)
this way you are sure to avoid any clashes with other plugins.