【发布时间】:2021-05-24 01:14:43
【问题描述】:
我为产品写了这个表格,里面有所有品牌,然后为品牌输入设置选择列表
class ProductForm(forms.ModelForm):
class Meta:
BRAND_CHOICE = Brand.objects.all()
model = Product
fields = '__all__'
widgets = {
'brand': forms.Select(choices=BRAND_CHOICE),
}
但运行时出错
python manage.py 迁移
我犯的一个错误
django.db.utils.OperationalError: no such table: app_product_brand
那么我如何检查数据库,如果表存在然后查询数据库?
【问题讨论】:
-
在运行 migrate 之前是否运行了
python manage.py makemigrations?
标签: django database django-queryset