Python Can';从另一个django应用程序迁移的t访问模型

Python Can';从另一个django应用程序迁移的t访问模型,python,django,migration,Python,Django,Migration,我的自定义逻辑迁移尝试从otherapp使用Model3,但在LookupError时失败:应用程序“otherapp”没有“Model3”模型。 Model3不是一个新的模型,它已经使用了一段时间,在迁移过程中,我可以在otherapp中访问其他模型 from __future__ import unicode_literals from django.db import migrations def update_items(apps, schema_editor): # a

我的自定义逻辑迁移尝试从
otherapp
使用
Model3
,但在
LookupError时失败:应用程序“otherapp”没有“Model3”模型。

Model3不是一个新的模型,它已经使用了一段时间,在迁移过程中,我可以在
otherapp
中访问其他模型

from __future__ import unicode_literals

from django.db import migrations


def update_items(apps, schema_editor):

    # apps shows references to models in 'otherapp'
    # This prints Model1, Model2 but is missing Model3
    print apps.all_models['otherapp'].keys()

    # This works
    OtherAppModel1 = apps.get_model('otherapp', 'Model1')

    # This fails: LookupError: App 'otherapp' doesn't have a 'model3' model.
    OtherAppModel3 = apps.get_model('otherapp', 'Model3')

    # This works but should not be done in a migration
    from otherapp.models import Model3

class Migration(migrations.Migration):

    dependencies = [
        ('thisapp', '0102_foo'),
    ]

    operations = [
        migrations.RunPython(update_items)
    ]

尝试将其他应用的最新迁移添加为依赖项。是否从其他应用导入一个模型并在第一个应用中导入另一个模型?尝试将其他应用的最新迁移添加为依赖项。是否从其他应用导入一个模型并在第一个应用中导入另一个模型?