I tried to put an app inside another app (Outer one is a facade into the inner one so it made sense to locate them that way), and it doesn’t create a table for the model in that inner app. Is this normal? (the app is installed, and registered with the admin)
Share
Django loads models by importing the
modelsmodule of every package in theINSTALLED_APPSsetting. For example, with anINSTALLED_APPSsetting of('django.contrib.admin', 'django.contrib.comments', 'spam.ham', and 'eggs'), Django will import models fromdjango.contrib.admin.models,django.contrib.comments.models,spam.ham.models, andeggs.models.If you are only listing your outer app in
INSTALLED_APPS(we’ll assume it’s namedeggs), then only the models fromeggs.modelsare being imported and created. To get the models installed from your inner app, you will need to add it to theINSTALLED_APPSas well, likeeggs.inner_app, so thateggs.inner_app.modelswill get imported. (To facilitate foreign keys, I’m pretty sure that if you import models from one app into another’smodels.pyfile, only the models defined in themodels.pyfile being scanned get created.)