11. Adding color class
class Color(models.Model):
name = models.CharField(max_length=200, null=True, blank=True)
code = models.CharField(max_length=200, null=True, blank=True) #? color code is a hex code
def __str__(self) :
return str(self.name)class ItemStock(models.Model):
product = models.ForeignKey(Product, blank=True, null=True, on_delete=models.SET_NULL) #? one itemstock is associated to a single product however one product can have many itemstocks
color = models.ForeignKey(Color, blank=True, null=True, on_delete=models.SET_NULL)
size = models.CharField(max_length=200, null=True, blank=True)
quantity = models.IntegerField(default=0)admin.site.register([Categoric, Client, Type, Product, ItemStock, Order, OrderedItem, Adres, Banner, Color])python manage.py makemigrationspython manage.py migrate

Last updated