Reputation:
I write this form for the product, that's got all brand and then set choice list for brand input
class ProductForm(forms.ModelForm):
class Meta:
BRAND_CHOICE = Brand.objects.all()
model = Product
fields = '__all__'
widgets = {
'brand': forms.Select(choices=BRAND_CHOICE),
}
but I take error when run
python manage.py migrate
an error that I taken
django.db.utils.OperationalError: no such table: app_product_brand
So how can I check DB and if tables exist then make a query to Database?
Upvotes: 1
Views: 2474
Reputation: 438
You can check in your models.py app_product_brand , if you have this model , if you are already having do
python manage.py makemigrations
python manage.py migrate app_product_brand
If not you can check all tables using this
from django.db import connection
all_tables = connection.introspection.table_names()
Upvotes: 2