1

我一直在用 htmx 实现这个主动搜索。我更改了设置,之后我的应用无法在此处运行是我设置的一部分

COMPRESS_FILTERS = {'css': ['libman.admin.PostCSSFilter']}

COMPRESS_ROOT = BASE_DIR / 'static'

COMPRESS_ENABLED = True
STATICFILES_FINDERS = [
    'compressor.finders.CompressorFinder',
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',]

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

STATICFILES_DIRS = [os.path.join(BASE_DIR,'static')]

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

我已经compressor添加到我安装的应用程序中

这就是我在我的libman应用程序管理员中所拥有的。

from compressor.filters import CompilerFilter
class PostCSSFilter(CompilerFilter):
    command = 'postcss'

当我将这两个应用到我的基本文件时,我得到了一个错误。

    {% compress css %}
      <link rel="stylesheet" href="{% static 'src/main.css' %}">
    {% endcompress %}
        <!-- new -->
    {% compress js %}
      <script type="text/javascript" src="{% static 'src/htmx.js' %}"></script>
    {% endcompress %}

我得到了下面的错误。有人可以帮我调试吗??

C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\views\debug.py:420: ExceptionCycleWarning: Cycle in the exception chain detected: exception 'Error 10061 connecting to 127.0.0.1:6379. No connection could be made because the target machine actively refused it.' encountered again.
  warnings.warn(
Internal Server Error: /library/home
Traceback (most recent call last):
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django_redis\cache.py", line 31, in _decorator
    return method(self, *args, **kwargs)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django_redis\cache.py", line 98, in _get
    return self.client.get(key, default=default, version=version, client=client)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django_redis\client\default.py", line 260, in get
    raise ConnectionInterrupted(connection=client) from e
django_redis.exceptions.ConnectionInterrupted: Redis ConnectionError: Error 10061 connecting to 127.0.0.1:6379. No connection could be made because the target machine actively refused it.

在处理上述异常的过程中,又出现了一个异常:

Traceback (most recent call last):
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
    response = get_response(request)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\handlers\base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\contrib\auth\decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "D:\Python\Django\Completed Projects\lib_system\Library-System\libman\views.py", line 273, in index
    return render(request, 'libman/home.html',{'books':books,'students':students,
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\shortcuts.py", line 19, in render
    content = loader.render_to_string(template_name, context, request, using=using)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\loader.py", line 62, in render_to_string
    return template.render(context, request)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\backends\django.py", line 61, in render
    return self.template.render(context)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\base.py", line 170, in render
    return self._render(context)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\base.py", line 162, in _render
    return self.nodelist.render(context)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\base.py", line 938, in render
    bit = node.render_annotated(context)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\base.py", line 905, in render_annotated
    return self.render(context)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\base.py", line 162, in _render
    return self.nodelist.render(context)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\base.py", line 938, in render
    bit = node.render_annotated(context)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\template\base.py", line 905, in render_annotated
    return self.render(context)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\compressor\templatetags\compress.py", line 143, in render
    return self.render_compressed(context, self.kind, self.mode, forced=forced)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\compressor\templatetags\compress.py", line 111, in render_compressed
    cache_key, cache_content = self.render_cached(compressor, kind, mode)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\compressor\templatetags\compress.py", line 89, in render_cached
    cache_key = get_templatetag_cachekey(compressor, mode, kind)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\compressor\cache.py", line 104, in get_templatetag_cachekey
    "templatetag.%s.%s.%s" % (compressor.cachekey, mode, kind))
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\compressor\base.py", line 200, in cachekey
    [self.content] + self.mtimes).encode(self.charset), 12)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\compressor\base.py", line 193, in mtimes
    return [str(get_mtime(value))
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\compressor\base.py", line 193, in <listcomp>
    return [str(get_mtime(value))
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\compressor\cache.py", line 110, in get_mtime
    mtime = cache.get(key)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django_redis\cache.py", line 91, in get
    value = self._get(key, default, version, client)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django_redis\cache.py", line 38, in _decorator
    raise e.__cause__
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\django_redis\client\default.py", line 258, in get
    value = client.get(key)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\redis\client.py", line 1606, in get
    return self.execute_command('GET', name)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\redis\client.py", line 898, in execute_command
    conn = self.connection or pool.get_connection(command_name, **options)
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\redis\connection.py", line 1192, in get_connection
    connection.connect()
  File "C:\Users\Ptar\AppData\Local\Programs\Python\Python39\lib\site-packages\redis\connection.py", line 563, in connect
    raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 10061 connecting to 127.0.0.1:6379. No connection could be made because the target machine actively refused it.
4

0 回答 0