I am outsourcing my models into packages in order to have a better overview. So the models.py of my app main looks like
from django.db import models
from models import *
And the actual models are in models/user.py, ...
So when I go back to prepare a migration:
python manage.py makemigrations main
Django won't detect any changes. Why?
-
Give a look to this post stackoverflow.com/questions/24912173/…coder3521– coder35212015年09月21日 11:43:41 +00:00Commented Sep 21, 2015 at 11:43
-
You have a models.py and a models directory in your main directory? Aren't you asking for confusion on which python will import? (See stackoverflow.com/questions/4092395/…) I would suggest renaming the directory to mymodels or similar. This may not actually be your issue, but it still makes my python-sense tingle.Foon– Foon2015年09月21日 12:52:07 +00:00Commented Sep 21, 2015 at 12:52
2 Answers 2
I had the same problem with migrating my models. so i changed the import methodology and instead of
from models import *
i tried this
from models.user import User, Device, ...
and it worked
Comments
Django looks into 'appname/models.py'. If you want this structure, you can use 'appname/user/models.py' and in INSTALLED_APPS 'appname.user', but it's better to use flat design: 'appname/models.py', 'user/models.py', ...