django | 根据 model 创建对应的表
代码如下:
from django.db import connections
with connections['db_to_create_a_table_in'].schema_editor() as schema_editor:
schema_editor.create_model(YourUnmanagedModelClass)
可通过错误捕获实现 create table if not exist
的效果。
Reference#
晚上吃饭想加个鸡腿 🍗