add: add order apis for admin panel
This commit is contained in:
18
core/apps/orders/migrations/0004_order_status.py
Normal file
18
core/apps/orders/migrations/0004_order_status.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 5.2 on 2025-09-03 16:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('orders', '0003_order_order_number'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='order',
|
||||
name='status',
|
||||
field=models.CharField(choices=[('PENDING', 'kutilmoqda'), ('PROCESSING', 'qayta ishlash'), ('SHIPPED', "jo'natilgan"), ('DELIVERED', 'yetkazib berildi'), ('CANCELLED', 'bekor qilingan')], default='kutilmoqda', max_length=20),
|
||||
),
|
||||
]
|
||||
@@ -6,17 +6,18 @@ from core.apps.products.models import Product
|
||||
|
||||
|
||||
class Order(BaseModel):
|
||||
# STATUS = (
|
||||
# ('', ''),
|
||||
# ('', ''),
|
||||
# ('', ''),
|
||||
# ('', ''),
|
||||
# ('', '')
|
||||
# )
|
||||
STATUS = (
|
||||
('PENDING', 'kutilmoqda'),
|
||||
('PROCESSING', 'qayta ishlash'),
|
||||
('SHIPPED', "jo'natilgan"),
|
||||
('DELIVERED', 'yetkazib berildi'),
|
||||
('CANCELLED', 'bekor qilingan')
|
||||
)
|
||||
|
||||
total_price = models.PositiveBigIntegerField(default=0)
|
||||
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='orders')
|
||||
order_number = models.PositiveBigIntegerField(default=1)
|
||||
# status = models.CharField(max_length=20, choices=STATUS)
|
||||
status = models.CharField(max_length=20, choices=STATUS, default='kutilmoqda')
|
||||
|
||||
def __str__(self):
|
||||
return f'{self.user} order'
|
||||
|
||||
@@ -61,5 +61,5 @@ class OrderListSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Order
|
||||
fields = [
|
||||
'id', 'total_price', 'items', 'created_at'
|
||||
'id', 'order_number', 'total_price', 'items', 'created_at'
|
||||
]
|
||||
Reference in New Issue
Block a user