我只是想向模型添加其他属性
class BookCardsModel(models.Model):
class Meta:
verbose_name = 'Card Books'
verbose_name_plural = 'Card Books'
book_cover = models.ImageField()
book_name = models.CharField(max_length=100)
book_subtitle = models.CharField(max_length=100)
book_description = models.TextField(max_length=300)
full_description = models.TextField(max_length=700)
book_quantity = models.IntegerField(default=0)
book_color = models.CharField(max_length=100, blank=True)
book_size = models.CharField(max_length=100, blank=True)
digital = models.BooleanField(default=False,null=True,blank=False)
更新 django 模型后,您需要创建新的迁移,然后进行迁移
您可以使用以下命令
python manage.py makemigrations # to make migrations
python manage.py migrate # to migrate
然后您的实际数据库将被更新并添加新列