changimg or editing existing models?

 say your current models is

    class Product(models.Model):

           product_id=models.AutoField

           name= models.CharField(max_length=50)

          desc=models.Charfield(max_length=300)

          pub_date=models.DateField()

if you want to add category image and subcategory


               class Product(models.Model):

           product_id=models.AutoField

           name= models.CharField(max_length=50)

          desc=models.Charfield(max_length=300)

          pub_date=models.DateField()

  ///you must add default values otherwise while making migration terminal will ask you some unnecessary things////

          category=models.CharField(max_length=50,default='')

          subcategory=models.CharField(max_length=100,default='')

         image=models.ImageField(upload_to='shop/images',default='')

    

Comments