Как исправить ошибку "config for 'compressor'" в Django - PullRequest
0 голосов
/ 28 декабря 2018

Я следую учебному пособию по Django-SHOP https://django -shop.readthedocs.io / en / latest / tutorial / intro.html # tutorial-populate-database-fixtures .После успешного объявления демонстрационной реализации я попытался запустить свое приложение.

Я получил трассировку:

            [2018-12-28 18:21:07,071 exception] ERROR: Internal Server Error: /
            Traceback (most recent call last):
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 109, in get_exception_response
                response = callback(request, **dict(param_dict, exception=exception))
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
                response = view_func(request, *args, **kwargs)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/views/defaults.py", line 45, in page_not_found
                body = template.render(context, request)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/backends/django.py", line 66, in render
                return self.template.render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 207, in render
                return self._render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 199, in _render
                return self.nodelist.render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 990, in render
                bit = node.render_annotated(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
                return self.render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/loader_tags.py", line 177, in render
                return compiled_parent._render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 199, in _render
                return self.nodelist.render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 990, in render
                bit = node.render_annotated(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
                return self.render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/loader_tags.py", line 177, in render
                return compiled_parent._render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 199, in _render
                return self.nodelist.render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 990, in render
                bit = node.render_annotated(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
                return self.render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/loader_tags.py", line 177, in render
                return compiled_parent._render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 199, in _render
                return self.nodelist.render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 990, in render
                bit = node.render_annotated(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
                return self.render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/classytags/core.py", line 153, in render
                return self.render_tag(context, **kwargs)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/sekizai/templatetags/sekizai_tags.py", line 93, in render_tag
                rendered_contents = nodelist.render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 990, in render
                bit = node.render_annotated(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
                return self.render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/classytags/core.py", line 153, in render
                return self.render_tag(context, **kwargs)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/cms/templatetags/cms_tags.py", line 499, in render_tag
                rendered_contents = nodelist.render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 990, in render
                bit = node.render_annotated(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/template/base.py", line 957, in render_annotated
                return self.render(context)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/classytags/core.py", line 153, in render
                return self.render_tag(context, **kwargs)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/sekizai/templatetags/sekizai_tags.py", line 98, in render_tag
                data = func(context, data, name)
              File "/var/www/vhosts/Tutorial/shoptutorial/bin/django-shop/shop/sekizai_processors.py", line 61, in compress
                compressable_node.render(context=context),
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/compressor/templatetags/compress.py", line 131, in render
                return self.render_compressed(context, self.kind, self.mode, forced=forced)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/compressor/templatetags/compress.py", line 103, in render_compressed
                cache_key, cache_content = self.render_cached(compressor, kind, mode)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/compressor/templatetags/compress.py", line 82, in render_cached
                cache_key = get_templatetag_cachekey(compressor, mode, kind)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/compressor/cache.py", line 97, in get_templatetag_cachekey
                "templatetag.%s.%s.%s" % (compressor.cachekey, mode, kind))
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
                res = instance.__dict__[self.name] = self.func(instance)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/compressor/base.py", line 177, in cachekey
                [self.content] + self.mtimes).encode(self.charset), 12)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
                res = instance.__dict__[self.name] = self.func(instance)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/compressor/base.py", line 172, in mtimes
                if kind == SOURCE_FILE]
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/compressor/cache.py", line 103, in get_mtime
                mtime = cache.get(key)
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/utils/functional.py", line 238, in inner
                self._setup()
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/utils/functional.py", line 386, in _setup
                self._wrapped = self._setupfunc()
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/compressor/cache.py", line 158, in <lambda>
                cache = SimpleLazyObject(lambda: caches[settings.COMPRESS_CACHE_BACKEND])
              File "/var/www/vhosts/Tutorial/shoptutorial/local/lib/python2.7/site-packages/django/core/cache/__init__.py", line 77, in __getitem__
                "Could not find config for '%s' in settings.CACHES" % alias
            InvalidCacheBackendError: Could not find config for 'compressor' in settings.CACHES
            [2018-12-28 18:21:07,076 basehttp] ERROR: "GET / HTTP/1.1" 500 27

В моем файле settings.py я следую этой конфигурации:

CACHES = {
    'default': {
        'BACKEND': 'redis_cache.RedisCache',
        'LOCATION': 'redis://{}:6379/1'.format(REDIS_HOST),
         "OPTIONS": {
             "PICKLE_VERSION": PICKLE_V,                                                                                                
         }
    },
    'compressor': {
        'BACKEND': 'redis_cache.RedisCache',
        'LOCATION': 'redis://{}:6379/2'.format(REDIS_HOST),
    }, 
    'select2': {
        'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
    },
}

Я ожидаю увидеть шаблон, и вместо этого я получил ошибку сервера (500).Моя ошибка, я думаю, связана с кешем. Есть идеи, как подойти к этому поведению?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...