0

The following diagram is from my database Database schema

I have the following model that represents that schema:

class Finalproduct (models.Model):

    idfinalproduct = models.AutoField(primary_key=True)
    idproduct = models.ForeignKey('Product',on_delete=models.CASCADE)
    idtaste= models.ForeignKey('Taste', on_delete=models.CASCADE)
    idpresentation = models.ForeignKey('Presentation', on_delete=models.CASCADE)
    idcategory = models.ForeignKey('Category', on_delete=models.CASCADE)
    cantidad = models.IntegerField()

    class Meta:
        unique_together = (("idproduct","idtaste","idpresentation","idcategory"),)

The cantidad field is not being added in my database table finalproduct. The following is the result of the migration in MySql: Mysql, table generated with model shown above

I have tried deleting my database, migrations, and the problem is never solved.

nthall
  • 2,847
  • 1
  • 28
  • 36
Uribe2304
  • 51
  • 1
  • 8

1 Answers1

0

Your integer field has to have a default value so try:

cantidad = models.IntegerField(default=0)
popcorn
  • 388
  • 1
  • 7
  • 28
  • No, everything seems to be ok. I tried to add the column in the initial001.py, but for some reason it tries to remove the column – Uribe2304 Oct 09 '19 at 15:02
  • Try to delete the files from migrations folders and only leave __init__.py there – popcorn Oct 09 '19 at 15:12