-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
67 lines (56 loc) · 2.13 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from django.db import models
from django.contrib.auth.models import User
from django.core.validators import MaxValueValidator,MinValueValidator
STATE_CHOICES = (
('Andaman & Nicobar Islands' , 'Andaman & Nicobar Islands'),
('Andhra Pradesh' , 'Andhra Pradesh'),
('Arunachal Pradesh' , 'Arunachal Pradesh'),
('Assam' , 'Assam'),
('Bihar' , 'Bihar'),
)
class Customer(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)
name = models.CharField(max_length=200)
locality = models.CharField(max_length=200)
city = models.CharField(max_length=50)
zipcode = models.IntegerField()
state = models.CharField(choices=STATE_CHOICES, max_length=50)
def __str__(self):
return str(self.id)
CATEGORY_CHOICES = (
('M', 'Mobile'),
('L', 'Laptop'),
('TW', 'Top Wear'),
('BW', 'Bottom Wear'),
)
class Product(models.Model):
title = models.CharField(max_length=100)
selling_price = models.FloatField()
discounted_price = models.FloatField()
description = models.TextField()
brand = models.CharField(max_length=100)
category = models.CharField(choices=CATEGORY_CHOICES,max_length=2)
product_image = models.ImageField(upload_to='productimg')
def __str__(self):
return str(self.id)
class Cart(models.Model):
user= models.ForeignKey(User, on_delete=models.CASCADE)
product = models.ForeignKey(Product, on_delete=models.CASCADE)
quantity = models.PositiveIntegerField(default=1)
def __str__(self):
return str(self.id)
STATUS_CHOICES = (
('Accepted', 'Accepted'),
('Packed','Packed'),
('On The Way','On The Way'),
('Delivered', 'Delivered'),
('Cancel','Cancel')
)
class OrderPlaced(models.Model):
user = models.ForeignKey(User,on_delete=models.CASCADE)
customer = models.ForeignKey(Customer,on_delete=models.CASCADE)
product = models.ForeignKey(Product,on_delete=models.CASCADE)
quantity = models.PositiveIntegerField(default=1)
ordered_date = models.DateTimeField(auto_now_add=True)
status = models.CharField(max_length=50,choices= STATUS_CHOICES,default='Pending')
# Create your models here.