Skip to content

Commit 19f631f

Browse files
committed
djangoplugins uniq constraint: use id instead of index
was getting error messages about duplicate keys, looks like the id counter is automatically incremented as a uniq field but that index field might not be as a plain integer field (not handled by postgres at all?)
1 parent e185083 commit 19f631f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

djangoplugins/management/commands/syncplugins.py

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

110-
for _i, (plugin, inst) in enumerate(self.available(src, dst, Plugin)):
110+
for plugin, inst in self.available(src, dst, Plugin):
111111
inst.point = point_inst
112112
inst.name = getattr(plugin, 'name', None)
113-
inst.index = _i
113+
inst.id = getattr(plugin, 'id')
114114
if hasattr(plugin, 'title'):
115115
inst.title = six.text_type(getattr(plugin, 'title'))
116116
inst.save()

djangoplugins/migrations/0002_add_id_to_plugins_uniq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ class Migration(migrations.Migration):
1414
operations = [
1515
migrations.AlterUniqueTogether(
1616
name='plugin',
17-
unique_together=set([('point', 'name', 'index')]),
17+
unique_together=set([('point', 'name', 'id')]),
1818
),
1919
]

0 commit comments

Comments
 (0)