Model not detected by Django, even with `app_label` referencing to an existing app

I have a Django project with an application called application.

The app is installed in the INSTALLED_APPS as follows:

'application.apps.MyAppConfig'

with the AppConfig:

### application/apps.py

class MyAppConfig(AppConfig):
    name = 'application'
    verbose_name = 'My App'
    label = 'application'

    path = f"{os.environ.get('APP_DIR')}/application"
    default = True

I have the models defined like this:

### data/models/basemodel.py

class MyBaseModel(models.Model):
   
   # ...  fields ...

   Meta:
      app_label: `application`

However, Django is not finding the models, and if I run makemigrations Django responds No changes detected, and on migrate, the app application does not appear on the Operations to perform.

The Model should be detected so the Django detects migrations to apply

===

Context:

  • Django Application reference: doc
  • Django Models reference: doc

I guess you want to have a single module per model ? If so, you need to import your models inside models\__init__ like so:

from .basemodel import BaseModel

I also suggest that you define __all__ inside your init file, in order to import your models easily in other parts of the app:

__all__ = ["BaseModel"]

from .basemodel import BaseModel
Back to Top