Update product slug field to include UUID in generation logic
This change modifies the `slug` field in the `Product` model to also populate from the `UUID` field, ensuring enhanced uniqueness and consistency. The migration file is included to apply this change to the database schema.
This commit is contained in:
parent
d4928db393
commit
f2e319f477
2 changed files with 20 additions and 1 deletions
19
core/migrations/0014_alter_product_slug.py
Normal file
19
core/migrations/0014_alter_product_slug.py
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 5.1.8 on 2025-04-30 13:42
|
||||||
|
|
||||||
|
import django_extensions.db.fields
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0013_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', 'brand.name', 'name'), unique=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -304,7 +304,7 @@ class Product(NiceModel):
|
||||||
verbose_name=_("part number"),
|
verbose_name=_("part number"),
|
||||||
)
|
)
|
||||||
slug = AutoSlugField(
|
slug = AutoSlugField(
|
||||||
populate_from=("category.name", "brand.name", "name"),
|
populate_from=("uuid", "category.name", "brand.name", "name"),
|
||||||
allow_unicode=True,
|
allow_unicode=True,
|
||||||
unique=True,
|
unique=True,
|
||||||
editable=False,
|
editable=False,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue