Reputation: 4504
I am trying to create a nested app in my django project, but makemigrations
is not detecting it. I have the following directory structure:
myproject/
├── db.sqlite3
├── manage.py
├── myproject
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── parentapp
├── admin.py
├── apps.py
├── childapp
│ ├── admin.py
│ ├── apps.py
│ ├── __init__.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── tests.py
│ └── views.py
├── __init__.py
├── migrations
│ └── __init__.py
├── models.py
├── tests.py
└── views.py
And here is some relevant code:
myproject/myproject/settings.py:
INSTALLED_APPS = [
...
'parentapp',
'parentapp.childapp',
]
myproject/parentapp/childapp/__init__.py:
default_app_config = "parentapp.childapp.apps.ChildAppConfig"
myproject/parentapp/childapp/apps.py:
from django.apps import AppConfig
class ChildAppConfig(AppConfig):
name = 'parentapp.childapp'
myproject/parentapp/childapp/models.py:
from django.db import models
class Child(models.Model):
class Meta:
app_label = "parentapp.childapp"
name = models.CharField(max_length=100)
I see the following behavior when trying to make migrations:
$ myproject/manage.py makemigrations
No changes detected
$ myproject/manage.py makemigrations childapp
No changes detected in app 'childapp'
$ myproject/manage.py makemigrations parentapp.childapp
'parentapp.childapp' is not a valid app label. Did you mean 'childapp'?
What am I doing wrong? I see loads of other reusable apps that have nested apps (django-allauth, for example).
Upvotes: 2
Views: 1841
Reputation: 2493
You need to remove the app_label
from Child.Meta
or to change it to a compatible app name (no ".", lowercase and underscore).
Upvotes: 2