Features: 1) Update product.slug to use AutoSlugField with adjusted populate_from order in migrations and model;
Fixes: 1) None; Extra: Refactor `product.slug` field declaration for improved readability in `models.py`.
This commit is contained in:
parent
b6ab56624b
commit
4b367944b9
2 changed files with 32 additions and 1 deletions
26
core/migrations/0031_alter_product_slug.py
Normal file
26
core/migrations/0031_alter_product_slug.py
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
# Generated by Django 5.2 on 2025-06-21 16:40
|
||||||
|
|
||||||
|
import django_extensions.db.fields
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("core", "0030_alter_category_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=("name", "brand__slug", "category__slug", "uuid"),
|
||||||
|
unique=True,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -358,7 +358,12 @@ class Product(ExportModelOperationsMixin("product"), NiceModel):
|
||||||
verbose_name=_("part number"),
|
verbose_name=_("part number"),
|
||||||
)
|
)
|
||||||
slug: str | None = AutoSlugField( # type: ignore
|
slug: str | None = AutoSlugField( # type: ignore
|
||||||
populate_from=("uuid", "category__slug", "brand__slug", "name"),
|
populate_from=(
|
||||||
|
"name",
|
||||||
|
"brand__slug",
|
||||||
|
"category__slug",
|
||||||
|
"uuid",
|
||||||
|
),
|
||||||
allow_unicode=True,
|
allow_unicode=True,
|
||||||
unique=True,
|
unique=True,
|
||||||
editable=False,
|
editable=False,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue