On Jan 20, 5:59 am, David Cramer <dcra...@gmail.com> wrote: > The first three have been huges ones with us. We're just now running > into the settings issue, but would love to see what people can come up > with for solutions (we dont have a good one).
The override_settings() idea that Eric Florenzano describes at http://djangodose.com/articles/2009/09/handling-development-staging-and-production-enviro/ with some improvements and fixes as described in the following http://djangodose.com/articles/2009/09/handling-development-staging-and-production-enviro/#comment-16302200 have made my life considerably easier. Hope the following helps others as well. # 1. # settings is a directory, containing host-specific overrides # and the generic override logic $ ls settings/ __init__.py override.py host1.py host2.py # 2. # __init__.py has the same contents that settings.py # usually has, except it automatically imports host-specific # settings in the end $ tail -2 settings/__init__.py override.override_settings('projectname', platform.node().split('.') [0], sys.modules[__name__]) # 3. # The generic override logic is as follows $ cat settings/override.py from django.utils.importlib import import_module import warnings def override_settings(package, name, settings_module): rel_path = 'settings.' + name try: override_module = import_module(rel_path, package=package) except ImportError: warnings.warn("Failed to import settings from '%s.%s'" % (package, rel_path)) else: for key in dir(override_module): if key.isupper() and not key.startswith('__'): setattr(settings_module, key, getattr(override_module, key))
-- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@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.