From 8883b9f43de6734888d38ba2505791be12e7c4c5 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Sat, 21 Feb 2026 22:13:36 +0300 Subject: [PATCH] feat(core): replace AutoSlugField with TweakedAutoSlugField for product slugs Updated `product.slug` to use `TweakedAutoSlugField` for improved functionality, allowing unicode, overwrite capabilities, and enhanced population logic. Adjusted the corresponding migration script to ensure seamless database schema updates. Also marked `brand.categories` as deprecated. --- ...ter_brand_categories_alter_product_slug.py | 39 +++++++++++++++++++ engine/core/models.py | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 engine/core/migrations/0055_alter_brand_categories_alter_product_slug.py diff --git a/engine/core/migrations/0055_alter_brand_categories_alter_product_slug.py b/engine/core/migrations/0055_alter_brand_categories_alter_product_slug.py new file mode 100644 index 00000000..25cfb69b --- /dev/null +++ b/engine/core/migrations/0055_alter_brand_categories_alter_product_slug.py @@ -0,0 +1,39 @@ +# Generated by Django 5.2.11 on 2026-02-21 19:12 + +from django.db import migrations, models + +import engine.core.utils.db + + +class Migration(migrations.Migration): + dependencies = [ + ("core", "0054_product_export_to_marketplaces"), + ] + + operations = [ + migrations.AlterField( + model_name="brand", + name="categories", + field=models.ManyToManyField( + blank=True, + help_text="DEPRECATED", + to="core.category", + verbose_name="DEPRECATED", + ), + ), + migrations.AlterField( + model_name="product", + name="slug", + field=engine.core.utils.db.TweakedAutoSlugField( + allow_unicode=True, + blank=True, + editable=False, + max_length=88, + null=True, + overwrite=True, + populate_from=("name", "brand__slug", "category__slug", "uuid"), + unique=True, + verbose_name="Slug", + ), + ), + ] diff --git a/engine/core/models.py b/engine/core/models.py index 5e0b9e3d..eaeaeb5b 100644 --- a/engine/core/models.py +++ b/engine/core/models.py @@ -664,7 +664,7 @@ class Product(ExportModelOperationsMixin("product"), NiceModel): help_text=_("part number for this product"), verbose_name=_("part number"), ) - slug = AutoSlugField( + slug = TweakedAutoSlugField( populate_from=( "name", "brand__slug",