[Fixed]-Usage related_name queryset with Django CMS plugin

0👍

Need add

def copy_relations(self, oldinstance):
    self.breakpoints = oldinstance.breakpoints.all()

to my PluginModel. http://docs.django-cms.org/en/3.2.2/how_to/custom_plugins.html#handling-relations

1👍

Something like this should work. @atterratio’s answer will only work for for many-to-many relationships:

class PluginModel(CMSPlugin):
    title = models.CharField(max_length=60)

    def copy_relations(self, oldinstance):
        for breakpoint in oldinstance.breakpoints.all():
            breakpoint.pk = None
            breakpoint.plugin_key = self
            breakpoint.save()

Leave a comment