-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Chris,
On 02/10/2012 05:36 AM, Chris Wilson wrote: >> But "mysite" is a package, and Django wants us to be able to import >> "mysite.settings" and "mysite.urls" (in fact, the latter is the >> default ROOT_URLCONF setting). In order to make that possible, >> setup_environ does some magic... This bit of clever causes a boat-load >> of problems... > > <http://groups.google.com/group/django-developers/browse_frm/thread/44b70a37ff73298b> > > > My question is, why exactly Django wants us to be able to import > "mysite.settings" and "mysite.urls"? Wouldn't it be much simpler and > better if we could just import settings and urls? > > As an experiment, I've removed the "setup_environ(settings_mod)" from my > manage.py, which adds the project's parent directory to the PYTHONPATH, > and it seems to work so far. I think that mod_wsgi uses an environment > without this addition as well, leading to tickets like this: > > <https://code.djangoproject.com/ticket/15058> > <https://code.djangoproject.com/ticket/16673> > > Is there any reason not to drop the project name part of > DJANGO_SETTINGS_MODULE and ROOT_URLCONF, to reduce the risk of > confusion, pollution, double imports and bad practice app coding in Django? If you follow that quoted thread to the end, you'll find that this problem has already been resolved in trunk :-) See https://docs.djangoproject.com/en/dev/releases/1.4/#updated-default-project-layout-and-manage-py for the release-notes summary. For the default project layout, I chose to resolve it in favor of having an outer "project package", as this namespaces the project better and avoids potential top-level namespace clashes with generic names like "settings" and "urls". However, it's easy enough to adjust the layout and imports for your own project to eliminate that project package and just use "import settings" and "import urls", if you prefer that. Carl -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk81NPMACgkQ8W4rlRKtE2fulACfQRFyBOBEdB5slItKesanxCr0 lXoAoM4i5LFMn3L2DOYqqyyOr+6WJ6hL =HWsX -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.