I did some digging today on the Django developer's list about solutions to
the dynamix population of urls.py based on a setting in the settings.py
file. A little bit of history, it would appear they discussed this very
concept 4ish years ago. There has also been a good amount of discussion
related to revamping the application loading process of Django in order to
make it more straightforward. The complaint most often has is that if an
application is put under installed_apps, shouldn't that take care of all
this setup for you?
With that being said - the consensus against having a dynamic generator is
that it introduces code that is somewhat 'magical' and has more break
potential. (And a guiding principle of Django is to avoid 'magic' code at
all costs) Rather, the potential answer seems to lie in thinking about and
treating urls.py as a settings file itself. (And thus, a urls.py.sample
could be used for version control while urls.py contains your local
settings)
To reiterate the options:
1) Create a dynamic urls.py pattern generator for a custom setting in
settings.py that lists all applications that need a urls.py entry
2) Treat urls.py like a settings file and have a urls.py.sample for version
control
My opinion is that while the first option is more powerful, the second is
simpler to implement (and the Django community seems to have bigger things
in the works that would potentially handle this in future releases).
Eric Helms