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()
- Shall I use django-dynamic-formset or is there a better solution?
- Assign existing ForeignKey to model fields via command line/script using pk or other means
Source:stackexchange.com