[Django]-ForeignKey to 'self' in sub-application throws error on makemigrations in Django project

0👍

As you mention, it seems to be a lookup error when the project is trying to locate your app due to the nested apps. This can be solved by specifying the app name with an app_label in the models internal meta class:

class SampleModel(models.Model):
    ...
    class Meta:
        app_label = 'app_two'
👤Johan

0👍

I was able to solve this by changing the app_label to 'app_one_app_two' in apps.py. Because django references this when registering the related models, it doesn’t break. All migrations are then registered under that label as well.

Leave a comment