add: add order apis for admin panel

This commit is contained in:
behruz-dev
2025-09-03 16:33:05 +05:00
parent c040d6f4c6
commit 1befa6625f
6 changed files with 64 additions and 11 deletions

View 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),
),
]

View File

@@ -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'

View File

@@ -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'
]