Skip to content

Commit 0fdd130

Browse files
committed
enable registering multiple plugins with same name
by enumerating index field and adding it to the unique key
1 parent 246804c commit 0fdd130

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

djangoplugins/management/commands/syncplugins.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ def plugins(self, point, point_inst):
106106
src = self.get_classes_dict(point.plugins)
107107
dst = self.get_instances_dict(point_inst.plugin_set.all())
108108

109-
for plugin, inst in self.available(src, dst, Plugin):
109+
for _i, (plugin, inst) in enumerate(self.available(src, dst, Plugin)):
110110
inst.point = point_inst
111111
inst.name = getattr(plugin, 'name', None)
112+
inst.index = _i
112113
if hasattr(plugin, 'title'):
113114
inst.title = six.text_type(getattr(plugin, 'title'))
114115
inst.save()

djangoplugins/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class Plugin(DirtyFieldsMixin, models.Model):
8585
objects = PluginManager()
8686

8787
class Meta:
88-
unique_together = (("point", "name"),)
88+
unique_together = (("point", "name", "index"),)
8989
order_with_respect_to = 'point'
9090
ordering = ('index', 'id')
9191

0 commit comments

Comments
 (0)