Update Product slug generation to include UUID

The migration alters the `slug` field to include `uuid` in its `populate_from` attributes. This ensures more robust and unique slug generation, improving data integrity and avoiding potential collisions.
This commit is contained in:
Egor Pavlovich Gorbunov 2025-05-05 15:56:21 +03:00
parent 4bd037b828
commit 4e04caf91d
2 changed files with 20 additions and 1 deletions

View file

@ -0,0 +1,19 @@
# Generated by Django 5.1.8 on 2025-05-05 12:56
import django_extensions.db.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('core', '0015_alter_product_slug'),
]
operations = [
migrations.AlterField(
model_name='product',
name='slug',
field=django_extensions.db.fields.AutoSlugField(allow_unicode=True, blank=True, editable=False, null=True, populate_from=('uuid', 'category__name', 'name'), unique=True),
),
]

View file

@ -304,7 +304,7 @@ class Product(NiceModel):
verbose_name=_("part number"),
)
slug = AutoSlugField(
populate_from=("category__name", "name"),
populate_from=("uuid", "category__name", "name"),
allow_unicode=True,
unique=True,
editable=False,