I am currently using Django==1.7.1
. I have some reusable apps with same module name. This also makes app labels of models same. This is actually conflicting. You can't use both module with same name in different libraries, in your INSTALLED_APPS
in your settings
file.
I solved this by adding an AppConfig
for the modules and changed their labels(app_label) to resolve confliction;
#librarayX.my_module.apps.py
from django.apps import AppConfig
class ModuleAppConfig(AppConfig):
name = 'libraryX.my_module'
label = "X_my_module"
verbose_name = "my_module"
#librarayY.my_module.apps.py
from django.apps import AppConfig
class ModuleAppConfig(AppConfig):
name = 'libraryY.my_module'
label = "Y_my_module"
verbose_name = "my_module"
#settings.py
....
INSTALLED_APPS=[
...
'libraryX.my_module.apps.ModuleAppConfig',
'libraryY.my_module.apps.ModuleAppConfig',
...
]
...
Now, I can add those app configs into my INSTALLED_APPS
instead of modules. Conflicting is just resolved. Everything is OK until that point.
Here is my problem; When I override the label of the AppConfig
, my models in that modules are not discovered by Django
. When I run;
python manage.py makemigrations
Nothing seems changed. Despite I remove all migrations files, it did not even create initial one. I think, it does not see the models. Whenever I remove overridden label field from my app config, the models are discoverable back again. So, don't think my models location is wrong.
This could also be bug, I don't know. But if I am doing something wrong, what could it be?
Thanks!