Django: Can I have an application in a subfolder of another application?

I tried to put the application in another application (the external is the facade in the internal, so it makes sense to find it this way), and it does not create a table for the model in this internal application. This is normal? (the application is installed and registered by the administrator)

+7
django
source share
1 answer

Django loads models by importing the models module of each package in the INSTALLED_APPS setting. For example, with the setting INSTALLED_APPS ('django.contrib.admin', 'django.contrib.comments', 'spam.ham', and 'eggs') , Django imports models from django.contrib.admin.models , django.contrib.comments.models , spam.ham.models and eggs.models .

If you specify only your external application in INSTALLED_APPS (suppose it is called eggs ), then only models from eggs.models are imported and created. To get the models installed from your internal application, you also need to add it to INSTALLED_APPS , for example, eggs.inner_app so that eggs.inner_app.models imported. (To facilitate foreign keys, I am sure that if you import models from one application into another models.py file, only the models defined in the scanned models.py file are models.py .)

+5
source share

All Articles