【发布时间】:2020-01-23 10:55:19
【问题描述】:
在创建data migrations with Django 时,您会创建一个类似combine_names(apps, schema_editor) 的函数。
本例中apps和schema_editor参数的类型是什么?
【问题讨论】:
在创建data migrations with Django 时,您会创建一个类似combine_names(apps, schema_editor) 的函数。
本例中apps和schema_editor参数的类型是什么?
【问题讨论】:
类型分别为django.db.migrations.state.StateApps 和django.db.backends.postgresql.schema.DatabaseSchemaEditor。
这使得带有类型提示的示例方法如下所示。
# …
from django.db.backends.postgresql.schema import DatabaseSchemaEditor
from django.db.migrations.state import StateApps
def combine_names(apps: StateApps, schema_editor: DatabaseSchemaEditor):
# …
【讨论】: