Migrating Django 1.7 Cannot Find Application

I create data transfer for the application Notification, here I use the model link,, Managerfrom the applicationaccounts

Manager = apps.get_model("accounts", "Manager")

It gives an error:

    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'

Although from the shell I tried something like and worked

>> from django.apps import apps
>> apps.get_app_config('accounts').get_model('Manager'.lower())
>> accounts.models.Manager

Any light on Why does it fail in the event of migration?

+4
source share
1 answer

Your problem is probably already resolved, but someone else may run into this issue.

If the Manager model is not in the same application where you are creating the migration, you need to add a dependency for the application accountsduring the migration process. Example:

class Migration(migrations.Migration):
    dependencies = [
        ('Current_App_Name', 'XYZ_Last_Migration_of_App'),
        ('accounts', '0012_auto_XYZ'),
        ...,
    ]`
    ...
+6
source

Source: https://habr.com/ru/post/1598649/


All Articles