I have a Django REST project where I created a directory called apps to store all my apps. Each app is added to the INSTALLED_APPS list in my settings file like this:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# APPS
'apps.accounts.apps.AccountsConfig',
'apps.ads.apps.AdsConfig',
]
But when I run python manage.py makemigrations, Django doesn’t detect any changes — it seems like it doesn’t recognize my apps at all. Can anyone help me figure out what might be wrong? Thanks a lot
2 Answers 2
Open
apps/accounts/apps.py(similar for your other apps like ads).You need to update the name attribute in the
AccountsConfigclass to match the full dotted path:-
from django.apps import AppConfig class AccountsConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'apps.accounts' # Change here Do the same for
apps/ads/apps.py:from django.apps import AppConfig class AdsConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'apps.ads' # Change hereAfter making these changes, run
python manage.py makemigrationsagain.
It should work, if not then please let me know.
1 Comment
The previous answer is correct about updating the name attribute, but I'd suggest also adding the label attribute to make your life easier when working with migrations.
In apps/accounts/apps.py:
from django.apps import AppConfig
class AccountsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.accounts' # Full dotted path to the app
label = 'accounts' # Short name for the app
And in apps/ads/apps.py:
from django.apps import AppConfig
class AdsConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.ads'
label = 'ads'
Why add label?
The label attribute allows you to reference the app by its short name in management commands. Without it, you'd have to use the full path like:
python manage.py makemigrations apps.accounts
But with the label set, you can simply use:
python manage.py makemigrations accounts
This keeps your commands cleaner and is especially helpful when you have deeply nested app structures.
After making these changes, run python manage.py makemigrations and it should detect your models properly.
Comments
Explore related questions
See similar questions with these tags.
AccountsConfigfor example?