Update Product slug field to use simpler populate_from sources
Revised the `populate_from` argument of the Product model's `slug` field to use only `category__name` and `name` for generation. This simplifies the slug creation logic and aligns with the updated migration `0015_alter_product_slug`.
This commit is contained in:
parent
3caab8f523
commit
b924797869
2 changed files with 20 additions and 1 deletions
19
core/migrations/0015_alter_product_slug.py
Normal file
19
core/migrations/0015_alter_product_slug.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# Generated by Django 5.1.8 on 2025-04-30 14:03
|
||||
|
||||
import django_extensions.db.fields
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0014_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=('category__name', 'name'), unique=True),
|
||||
),
|
||||
]
|
||||
|
|
@ -304,7 +304,7 @@ class Product(NiceModel):
|
|||
verbose_name=_("part number"),
|
||||
)
|
||||
slug = AutoSlugField(
|
||||
populate_from=("uuid", "category.name", "brand.name", "name"),
|
||||
populate_from=("category__name", "name"),
|
||||
allow_unicode=True,
|
||||
unique=True,
|
||||
editable=False,
|
||||
|
|
|
|||
Loading…
Reference in a new issue