Add human-readable ID field to Order model
Introduced a `human_readable_id` field to the Order model to provide a concise and recognizable identifier, initialized with a default generator. Updated the field to enforce uniqueness to ensure consistent identification across orders.
This commit is contained in:
parent
131258517f
commit
0c1caa422c
2 changed files with 38 additions and 0 deletions
19
core/migrations/0017_order_human_readable_id.py
Normal file
19
core/migrations/0017_order_human_readable_id.py
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 5.1.8 on 2025-05-06 13:58
|
||||||
|
|
||||||
|
import core.utils
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0016_alter_product_slug'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='order',
|
||||||
|
name='human_readable_id',
|
||||||
|
field=models.CharField(default=core.utils.generate_human_readable_id, help_text='a human-readable identifier for the order', max_length=6, verbose_name='human readable id'),
|
||||||
|
),
|
||||||
|
]
|
||||||
19
core/migrations/0018_alter_order_human_readable_id.py
Normal file
19
core/migrations/0018_alter_order_human_readable_id.py
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 5.1.8 on 2025-05-06 13:58
|
||||||
|
|
||||||
|
import core.utils
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('core', '0017_order_human_readable_id'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='order',
|
||||||
|
name='human_readable_id',
|
||||||
|
field=models.CharField(default=core.utils.generate_human_readable_id, help_text='a human-readable identifier for the order', max_length=6, unique=True, verbose_name='human readable id'),
|
||||||
|
),
|
||||||
|
]
|
||||||
Loading…
Reference in a new issue