Django sub-applications & module structure

Posted by Rob Golding on Stack Overflow See other posts from Stack Overflow or by Rob Golding
Published on 2010-04-11T15:26:53Z Indexed on 2010/04/11 15:33 UTC
Read the original article Hit count: 246

Filed under:
|
|

I am developing a Django application, which is a large system that requires multiple sub-applications to keep things neat. Therefore, I have a top level directory that is a Django app (as it has an empty models.py file), and multiple subdirectories, which are also applications in themselves.

The reason I have laid my application out in this way is because the sub-applications are separated, but they would never be used on their own, outside the parent application. It therefore makes no sense to distribute them separately.

When installing my application, the settings file has to include something like this:

INSTALLED_APPS = (
    ...
    'myapp',
    'myapp.subapp1',
    'myapp.subapp2',
    ...
)

...which is obviously suboptimal. This also has the slightly nasty result of requiring that all the sub-applications are referred to by their "inner" name (i.e. subapp1, subapp2 etc.). For example, if I want to reset the database tables for subapp1, I have to type:

python manage.py reset subapp1

This is annoying, especially because I have a sub-app called core - which is likely to conflict with another application's name when my application is installed in a user's project.

Am I doing this completely wrongly, or is there away to force these "inner" apps to be referred to by their full name?

© Stack Overflow or respective owner

Related posts about django

Related posts about python