如何解决django.db.utils.OperationalError: no such columns问题

问题描述 投票:0回答:1

enter image description here

我只是想向模型添加其他属性

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) 
python django sqlite django-rest-framework pycharm
1个回答
0
投票

更新 django 模型后,您需要创建新的迁移,然后进行迁移

您可以使用以下命令

python manage.py makemigrations # to make migrations
python manage.py migrate # to migrate

然后您的实际数据库将被更新并添加新列

© www.soinside.com 2019 - 2024. All rights reserved.