feat: add self-referencing parent field to Category model and rename Product table to api_product
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 23s
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 23s
This commit is contained in:
parent
f904cad860
commit
d3a1c243ea
2 changed files with 24 additions and 0 deletions
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Generated by Django 6.1 on 2026-08-16 09:56
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('products', '0002_alter_product_options'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='category',
|
||||||
|
name='parent',
|
||||||
|
field=models.ForeignKey(blank=True, db_column='parent_id', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='subcategories', to='products.category'),
|
||||||
|
),
|
||||||
|
migrations.AlterModelTable(
|
||||||
|
name='product',
|
||||||
|
table='api_product',
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -6,6 +6,7 @@ class Category(models.Model):
|
||||||
slug = models.SlugField(max_length=100, unique=True, blank=True)
|
slug = models.SlugField(max_length=100, unique=True, blank=True)
|
||||||
is_active = models.BooleanField(default=True)
|
is_active = models.BooleanField(default=True)
|
||||||
sort_order = models.IntegerField(default=0)
|
sort_order = models.IntegerField(default=0)
|
||||||
|
parent = models.ForeignKey('self', on_delete=models.SET_NULL, null=True, blank=True, related_name='subcategories', db_column='parent_id')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name_plural = "Categories"
|
verbose_name_plural = "Categories"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue