feat: added seo template and prioduct.slug
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
# Generated by Django 5.1.3 on 2024-11-22 19:53
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.utils.text import slugify
|
||||
|
||||
|
||||
def add_product_slug(apps, schema_editor):
|
||||
Product = apps.get_model("shop", "Product")
|
||||
|
||||
for product in Product.objects.all():
|
||||
product.slug = slugify(product.name)[:128]
|
||||
product.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("shop", "0003_alter_brand_creation_date_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelOptions(
|
||||
name="product",
|
||||
options={
|
||||
"ordering": ("id",),
|
||||
"verbose_name": "producto",
|
||||
"verbose_name_plural": "productos",
|
||||
},
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="product",
|
||||
name="slug",
|
||||
field=models.SlugField(
|
||||
blank=True, default="", max_length=128, null=True, verbose_name="Slug"
|
||||
),
|
||||
),
|
||||
migrations.RunPython(
|
||||
add_product_slug,
|
||||
)
|
||||
]
|
||||
Reference in New Issue
Block a user