2

I essentially have the following issue:

Say, the model classes I define are in /app/cog/models.py, but Django only checks for them in /app/models.py . Is there any way to let Django dynamically read all the model classes in all models.py files in all subpackages of app?

It might be noteworthy that I really want to follow Django's philosophy concerning apps, which includes "all apps are independent from each other". So, I don't want to give those subpackages their own apps, or otherwise people who use my app would possibly end up with 50 apps after some time (as these subpackages simply extend the functionality of the app, and there will probably be a lot of them).

1 Answers1

0

There are two options:

  1. Along with app, also add app.cog to INSTALLED_APPS
  2. Or, include app/cog/models.py in app/models.py (i.e. from .cog.models import * or from .cog.models import model1, model2)
jatinderjit
  • 1,359
  • 8
  • 21