django-rosetta error: You can't use the CacheRosettaStorage

django-rosetta error: You can't use the CacheRosettaStorage

我正在使用 django-rosetta 应用程序,它可以在没有 CACHES 设置的情况下进行开发,但在产品上我有如下设置:

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '127.0.0.1:11211',
    }
}

问题是在prod下它养育了我

django.core.exceptions.ImproperlyConfigured:
You can't use the CacheRosettaStorage if your cache isn't correctly set up, 
please double check your Django DATABASES setting and that the cache server is responding

数据库设置很简单

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

因此,如异常消息所述:

double check your Django DATABASES setting and that the cache server is responding

我做到了,即使我的 memchached 工作正常我决定重新安装它,而且,作为魔术,它成功了!

在那之前我改变了我的 CACHES

CACHES = {
 'default': {
    'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
    'LOCATION': '127.0.0.1:11211',
 },
 'rosetta': {
    'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
    'LOCATION': '/var/tmp/django_cache',
 }
}

Django rosetta 将使用键 rosetta 如果存在具有此名称的缓存,或者 default 如果不存在。使用 FileBasedCache 时没有启动任何错误,所以我意识到问题出在 MemcachedCache 上。但是,重新安装后,它起作用了。