I'm having trouble actually applying migrations with my models app in my sample django project. I followed the advice at this thread but it's still not working.
What I think is unique about this sample project against the one used in the above link is that the models are stored in their own app, in separate files within that app; one file per model.
I'm able to makemigration
fine, but when I go to migrate
the changes, django says that there are no migrations to apply, despite there being a migration file within the models app.
Below is my project structure:
| db.sqlite3
| manage.py
|
+---project
| settings.py
| urls.py
| wsgi.py
| __init__.py
|
+---main
| | admin.py
| | forms.py
| | tests.py
| | urls.py
| | views.py
| | __init__.py
| |
| +---migrations
| | __init__.py
| |
| +---static
| \---templates
| \---main
| login.html
| register.html
|
+---models
| | answer.py
| | application.py
| | apps.py
| | business.py
| | group.py
| | question.py
| | user.py
| | __init__.py
| |
| \---migrations
| 0001_initial.py
| __init__.py
|
\---templates
\---_layouts
base.html
I am stumped, and can't find a reason why django can't apply the migration that it itself made.
Thanks in advance.
Update:
I've added an 'apps.py' to the models 'app' with a sub-classed AppConfig as suggested by Daniel, but it gives the same result. The modified .py code is below:
apps.py:
from django.apps import AppConfig
class ModelsConfig(AppConfig):
name = 'models'
verbose_name = "Models"
init.py for the models app:
from user import UserModel
from business import BusinessModel
from application import ApplicationModel
from group import GroupModel
from question import QuestionModel
from answer import AnswerModel
default_app_config = 'models.apps.ModelsConfig'