Skip to content

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

Allow unicode in slug fields

IKarbowiak01491277f69c
diff --git a/saleor/product/migrations/0119_auto_20200713_0851.py b/saleor/product/migrations/0119_auto_20200713_0851.py
new file mode 100644
index 0000000000..affd82c593
--- /dev/null
+++ b/saleor/product/migrations/0119_auto_20200713_0851.py
@@ -0,0 +1,43 @@
+# Generated by Django 3.0.6 on 2020-07-13 08:51
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("product", "0118_populate_product_variant_price"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="attribute",
+ name="slug",
+ field=models.SlugField(allow_unicode=True, max_length=250, unique=True),
+ ),
+ migrations.AlterField(
+ model_name="attributevalue",
+ name="slug",
+ field=models.SlugField(allow_unicode=True, max_length=255),
+ ),
+ migrations.AlterField(
+ model_name="category",
+ name="slug",
+ field=models.SlugField(allow_unicode=True, max_length=255, unique=True),
+ ),
+ migrations.AlterField(
+ model_name="collection",
+ name="slug",
+ field=models.SlugField(allow_unicode=True, max_length=255, unique=True),
+ ),
+ migrations.AlterField(
+ model_name="product",
+ name="slug",
+ field=models.SlugField(allow_unicode=True, max_length=255, unique=True),
+ ),
+ migrations.AlterField(
+ model_name="producttype",
+ name="slug",
+ field=models.SlugField(allow_unicode=True, max_length=255, unique=True),
+ ),
+ ]
diff --git a/saleor/product/models.py b/saleor/product/models.py
index baaaf973fc..13682116f9 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -43,7 +43,7 @@ if TYPE_CHECKING:
class Category(MPTTModel, ModelWithMetadata, SeoModel):
name = models.CharField(max_length=250)
- slug = models.SlugField(max_length=255, unique=True)
+ slug = models.SlugField(max_length=255, unique=True, allow_unicode=True)
description = models.TextField(blank=True)
description_json = JSONField(blank=True, default=dict)
parent = models.ForeignKey(
@@ -89,7 +89,7 @@ class CategoryTranslation(SeoModelTranslation):
class ProductType(ModelWithMetadata):
name = models.CharField(max_length=250)
- slug = models.SlugField(max_length=255, unique=True)
+ slug = models.SlugField(max_length=255, unique=True, allow_unicode=True)
has_variants = models.BooleanField(default=True)
is_shipping_required = models.BooleanField(default=True)
is_digital = models.BooleanField(default=False)
@@ -232,7 +232,7 @@ class Product(SeoModel, ModelWithMetadata, PublishableModel):
ProductType, related_name="products", on_delete=models.CASCADE
)
name = models.CharField(max_length=250)
- slug = models.SlugField(max_length=255, unique=True)
+ slug = models.SlugField(max_length=255, unique=True, allow_unicode=True)
description = models.TextField(blank=True)
description_json = SanitizedJSONField(
blank=True, default=dict, sanitizer=clean_draft_js
@@ -663,7 +663,7 @@ class AttributeQuerySet(BaseAttributeQuerySet):
class Attribute(ModelWithMetadata):
- slug = models.SlugField(max_length=250, unique=True)
+ slug = models.SlugField(max_length=250, unique=True, allow_unicode=True)
name = models.CharField(max_length=255)
input_type = models.CharField(
@@ -736,7 +736,7 @@ class AttributeTranslation(models.Model):
class AttributeValue(SortableModel):
name = models.CharField(max_length=250)
value = models.CharField(max_length=100, blank=True, default="")
- slug = models.SlugField(max_length=255)
+ slug = models.SlugField(max_length=255, allow_unicode=True)
attribute = models.ForeignKey(
Attribute, related_name="values", on_delete=models.CASCADE
)
@@ -823,7 +823,7 @@ class CollectionProduct(SortableModel):
class Collection(SeoModel, ModelWithMetadata, PublishableModel):
name = models.CharField(max_length=250, unique=True)
- slug = models.SlugField(max_length=255, unique=True)
+ slug = models.SlugField(max_length=255, unique=True, allow_unicode=True)
products = models.ManyToManyField(
Product,
blank=True,
diff --git a/saleor/warehouse/migrations/0010_auto_20200713_0839.py b/saleor/warehouse/migrations/0010_auto_20200713_0839.py
new file mode 100644
index 0000000000..4a7c84e36c
--- /dev/null
+++ b/saleor/warehouse/migrations/0010_auto_20200713_0839.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.6 on 2020-07-13 08:39
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ("warehouse", "0009_remove_invalid_allocation"),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name="warehouse",
+ name="slug",
+ field=models.SlugField(allow_unicode=True, max_length=255, unique=True),
+ ),
+ ]
diff --git a/saleor/warehouse/models.py b/saleor/warehouse/models.py
index 96a73993c3..b994ff33fa 100644
--- a/saleor/warehouse/models.py
+++ b/saleor/warehouse/models.py
@@ -27,7 +27,7 @@ class WarehouseQueryset(models.QuerySet):
class Warehouse(models.Model):
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
name = models.CharField(max_length=250)
- slug = models.SlugField(max_length=255, unique=True)
+ slug = models.SlugField(max_length=255, unique=True, allow_unicode=True)
company_name = models.CharField(blank=True, max_length=255)
shipping_zones = models.ManyToManyField(
ShippingZone, blank=True, related_name="warehouses"