【问题标题】:What are the types of method parameters in data migrations?数据迁移中的方法参数有哪些类型?
【发布时间】:2020-01-23 10:55:19
【问题描述】:

在创建data migrations with Django 时,您会创建一个类似combine_names(apps, schema_editor) 的函数。

本例中appsschema_editor参数的类型是什么?

【问题讨论】:

    标签: django django-migrations


    【解决方案1】:

    类型分别为django.db.migrations.state.StateAppsdjango.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):
        # …
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-23
      • 1970-01-01
      • 2011-10-14
      • 2012-08-16
      相关资源
      最近更新 更多