我正在为app创建一个数据迁移Notification,在这里我正在使用Managerapp 的模型引用accounts
Manager = apps.get_model("accounts", "Manager")
Run Code Online (Sandbox Code Playgroud)
它抛出错误:
self.code(from_state.render(), schema_editor)
File "/home/notifications/migrations/0004_auto_20150720_0127.py", line 12, in set_notification_setttings
Manager = apps.get_model("accounts", "Manager")
File "/home/local/lib/python2.7/site-packages/django/apps/registry.py", line 202, in get_model
return self.get_app_config(app_label).get_model(model_name.lower())
File "/home/local/lib/python2.7/site-packages/django/apps/registry.py", line 150, in get_app_config
raise LookupError("No installed app with label '%s'." % app_label)
LookupError: No installed app with label 'accounts'
Run Code Online (Sandbox Code Playgroud)
虽然从shell我尝试了类似的东西,它的工作原理
>> from django.apps import apps
>> apps.get_app_config('accounts').get_model('Manager'.lower())
>> accounts.models.Manager
Run Code Online (Sandbox Code Playgroud)
关于为什么在迁移的情况下它失败了?