Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Define name of collection as unique

Mira Szewczyk93d910d37fb1
diff --git a/saleor/product/migrations/0026_auto_20170102_0927.py b/saleor/product/migrations/0026_auto_20170102_0927.py
index 4778bd2265..7b615f5e86 100644
--- a/saleor/product/migrations/0026_auto_20170102_0927.py
+++ b/saleor/product/migrations/0026_auto_20170102_0927.py
@@ -16,7 +16,7 @@ class Migration(migrations.Migration):
name='Collection',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
- ('name', models.CharField(max_length=128, verbose_name='name')),
+ ('name', models.CharField(max_length=128, verbose_name='name', unique=True,)),
('products', models.ManyToManyField(to='product.Product')),
],
),
diff --git a/saleor/product/models.py b/saleor/product/models.py
index 2c1a3aa837..f02d069514 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -380,7 +380,7 @@ class VariantImage(models.Model):
@python_2_unicode_compatible
class Collection(models.Model):
name = models.CharField(
- pgettext_lazy('Collection field', 'name'), max_length=128)
+ pgettext_lazy('Collection field', 'name'), max_length=128, unique=True)
products = models.ManyToManyField(Product)
def __str__(self):