I created an app inside my application "inventory_management" by django-admin startapp testing
The project directory is shown below where emporium_apparel is my main project and testing is my sub app
when I run python manage.py makemigrations
it gives
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\mhashirhassan22\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\mhashirhassan22\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\__init__.py", line 377, in execute
django.setup()
File "C:\Users\mhashirhassan22\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\mhashirhassan22\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\mhashirhassan22\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Users\mhashirhassan22\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'testing'
If an application is nested and can not be imported from the Python path than you must write a complete path in INSTALLED_APPS
, e.g. inventory_management.testing
in your case. The name of application will be only the last part, e.g. testing
. That is used in default tables names and also in migrations. It is similar to "django.contrib.admin" that is in INSTALLED_APPS, but the short app name is "admin". That name must be unique in your project.
The name "testing" seems very general and it could be a problem. If you encounter a name conflict with another packages that have an application named "testing", you can fix it by another name by advanced configuration of the project with apps module, without changing anything in any application.
Django is more general and there is no concept of "sub application". Any application can depend on another application regardless whether it is inside its directory or not.