Django_Model
from django.db import models
CATEGORY_CHOICES = (
('M', 'Mobile'),
('L', 'Laptop'),
('TW', 'Top Wear'),
('BW', 'Bottom Wear'),
)
Product Model
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)
Cart Model
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)
Or
Models/
__init__.py
product.py
cart.py
__init__.py
from .products import Product
from .catagory import Category
from .orders import Order
from .customer import Customer
Comments
Post a Comment