-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
32 lines (26 loc) · 974 Bytes
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from tkinter import CASCADE
from django.db import models
from django.contrib.auth import get_user_model
# Create your models here.
User = get_user_model()
class Order(models.Model):
SIZES=(
('SMALL', 'small'),
('MEDIUM', 'medium'),
('LARGE', 'large'),
('EXTRS_LARGE', 'extraLarge'),
)
ORDER_STATUS = (
('PENDING', 'pending'),
('IN_TRANSIT', 'inTransit'),
('DELIVERED', 'delivered'),
('CANCELED', 'canceled'),
)
customer = models.ForeignKey(User, on_delete=models.CASCADE)
size = models.CharField(max_length=20, choices=SIZES, default=SIZES[0][0])
order_status = models.CharField(max_length=20, choices=ORDER_STATUS, default=ORDER_STATUS[0][0])
quantity = models.IntegerField()
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return f"<Order {self.size} by {self.customer.id}"