A fourth way: the django config is a template, with entries like:
settings.py:
CACHES = {
'default': { 'BACKEND' : 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION' : [ {% for IP in MEMCACHED_SERVERS %}'{{IP}}:{{MEMCACHED_PORT}}', {% endfor %} ],
},
Yes, that's a django template in python code. Upon deployment, my fabfile renders the settings file along with various other config files. This makes sure that {{MEMCACHED_PORT}} doesn't accidentally say one thing in settings.py, and another in memcached.conf.
This also allows me to keep my sitewide settings in a single file or two, namely a module in the fabfile folder.
It feels a little dirty to do things this way (though I can't figure out why), but it's saved me a lot of headaches.
settings.py:
Yes, that's a django template in python code. Upon deployment, my fabfile renders the settings file along with various other config files. This makes sure that {{MEMCACHED_PORT}} doesn't accidentally say one thing in settings.py, and another in memcached.conf.This also allows me to keep my sitewide settings in a single file or two, namely a module in the fabfile folder.
It feels a little dirty to do things this way (though I can't figure out why), but it's saved me a lot of headaches.