python 模型注册但不创建表

8ehkhllq  于 2023-01-29  发布在  Python
关注(0)|答案(1)|浏览(82)

在我的django应用程序上,我尝试注册模型,python www.example.com makemigrations,migrate工作,但在admin上找不到数据库表。manage.py makemigrations , migrate works , but no database table found on admin..

网站admin.py

from django.contrib import admin..
from .models import Product

class ProductAdmin(admin.ModelAdmin):
    prepopulated_fields = {'slug': ('product_name',)}
    list_display = ('product_name', 'price', 'stock', 'category', 'modified_date', 'is_available')

admin.site.register(Product, ProductAdmin)
31moq8wy

31moq8wy1#

首先,确保您的应用程序已在INSTALLED APPS内的settings.py文件中注册
然后运行python manage.py appname,然后作为python manage.py migrate appname迁移

相关问题