This is using Django 1.7 and Django CMS 3.1.0.
I've had a large Django project that has been in production for months without any issue. I'm currently adding Django CMS to it and found that if my cache is offline, I cannot issue any management commands without getting an exception. It used to work fine until I added Django CMS to my project.
This can be replicated by:
Manually installing Django CMS by following the instructions in the documentation.
Setting a default cache that connects to a cache service that can be offline. In my case I connect to a Redis server which is for my Django project's use only. This server is started manually before I run
manage.py runserver
in development and before my web application is brought online in production. Turning on the cache service makes the issue go away but sometimes I want to run some management commands with the cache service turned off.
If I run any management command when my Redis instance is offline, I get a failure. For instance, if I just run ./manage.py
without a command, I get a trace like this one:
Traceback (most recent call last):
File "./manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "env/local/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "env/local/lib/python2.7/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "env/local/lib/python2.7/site-packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "env/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 23, in autodiscover
autodiscover_modules('admin', register_to=site)
File "env/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 74, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "env/local/lib/python2.7/site-packages/cms/admin/__init__.py", line 11, in <module>
plugin_pool.plugin_pool.discover_plugins()
File "env/local/lib/python2.7/site-packages/cms/plugin_pool.py", line 33, in discover_plugins
invalidate_cms_page_cache()
File "env/local/lib/python2.7/site-packages/cms/views.py", line 335, in invalidate_cms_page_cache
version = _get_cache_version()
File "env/local/lib/python2.7/site-packages/cms/views.py", line 280, in _get_cache_version
version = cache.get(CMS_PAGE_CACHE_VERSION_KEY)
File "env/local/lib/python2.7/site-packages/django_redis/cache.py", line 30, in _decorator
raise e.parent
redis.exceptions.ConnectionError: Error 2 connecting to unix socket: /var/tmp/foo/redis/foo_dev.redis.sock. No such file or directory.
If I just remove the cms
app from INSTALLED_APPS
, this is enough to prevent the problem but this is not an acceptable fix.
Is there a way I can fix this without removing Django CMS or having to turn on my cache service before I issue any management command?