From e99ae9e85c02720f225c52207cd43692aa452ea7 Mon Sep 17 00:00:00 2001 From: Egor fureunoir Gorbunov Date: Sat, 21 Jun 2025 19:29:43 +0300 Subject: [PATCH] Features: 1) Alter `category.slug` to populate only from `name` and enable null values in migration. Fixes: 1) None. Extra: 1) Removed `parent__slug` from `populate_from` in `category.slug` field in models for consistency. --- core/migrations/0029_alter_category_slug.py | 26 +++++++++++++++++++++ core/models.py | 2 +- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 core/migrations/0029_alter_category_slug.py diff --git a/core/migrations/0029_alter_category_slug.py b/core/migrations/0029_alter_category_slug.py new file mode 100644 index 00000000..1c11d24d --- /dev/null +++ b/core/migrations/0029_alter_category_slug.py @@ -0,0 +1,26 @@ +# Generated by Django 5.2 on 2025-06-21 16:29 + +import django_extensions.db.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("core", "0028_alter_category_slug_alter_product_slug"), + ] + + operations = [ + migrations.AlterField( + model_name="category", + name="slug", + field=django_extensions.db.fields.AutoSlugField( + allow_unicode=True, + blank=True, + editable=False, + null=True, + populate_from=("name",), + unique=True, + ), + ), + ] diff --git a/core/models.py b/core/models.py index 9eedd3e7..e50923d9 100644 --- a/core/models.py +++ b/core/models.py @@ -214,7 +214,7 @@ class Category(ExportModelOperationsMixin("category"), NiceModel, MPTTModel): ) slug: str = AutoSlugField( # type: ignore - populate_from=("name", "parent__slug"), + populate_from=("name",), allow_unicode=True, unique=True, editable=False,