Django Compressor TemplateDoesNotExists Error

50 Views Asked by At

I have followed the guide of setting up the django compressor from flowbite docs and the official ones.

However is i move the link tag with my tailwind output file inside the compressor tags it throws TemplateDoesNotExist. I cannot figure out what is wrong. If i change the paths it cannot locate the file at all - so i quess the paths are correct.

I can also see that it generates a cache folder inside my static dirs

Here is the relevant sections from settings.py


INSTALLED_APPS = [
    'core.apps.CoreConfig',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'compressor'
]

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [BASE_DIR / 'templates'],
        'APP_DIRS': False,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, "frontend/static")]
STATIC_ROOT = os.path.join(BASE_DIR, "static_root")
STATICFILES_FINDERS = ('django.contrib.staticfiles.finders.FileSystemFinder',
                       'django.contrib.staticfiles.finders.AppDirectoriesFinder',
                       'compressor.finders.CompressorFinder',)
COMPRESS_ENABLED = True
COMPRESS_ROOT = os.path.join(BASE_DIR, "frontend/static")

and my test.html page:

{% load static %}
{% load compress %}

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>

    {% compress css %}
    <link rel="stylesheet" href="/static/style.css">
    {% endcompress %}

     

  </head>
  <body>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/flowbite/2.2.1/flowbite.min.js"></script>
  </body>
</html>

this is the folder structure from root:

folders

Error: enter image description here

I followed docs but cannot get the compressor to work

0

There are 0 best solutions below