Hiro3
Hiro3

Reputation: 201

Django Compressor not working in production

I want to use django_compressor but it's not working in my production environment.

In development (DEBUG=True), it's working and created .sass-cache & CACHE folders.

My settings.py is

DEBUG = False
TEMPLATE_DEBUG = False
INSTALLED_APPS = (
    ...,
    'django.contrib.staticfiles',
    'compressor',
    'myapp',
)
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'com.app.static')↲
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'static'),
)
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
)
COMPRESS_ENABLED = True
COMPRESS_ROOT = STATIC_ROOT
COMPRESS_PRECOMPILERS = (
    ('text/x-scss', 'sass --scss {infile} {outfile}'),
)
MEDIA_URL = '/media/'

scss file put template directory on app.

{% load staticfiles %}
{% load compress %}
<html>
<head>
    {% compress css %}
        <link rel='stylesheet' type='text/scss' href="{% static 'top/css/top.scss' %}" charset='utf-8'>
    {% endcompress %}
</head>
</html>

Upvotes: 5

Views: 5603

Answers (2)

Hiro3
Hiro3

Reputation: 201

Add this to settings.py

COMPRESS_OFFLINE = True

and compress

python manage.py compress

Upvotes: 6

Fanis Despoudis
Fanis Despoudis

Reputation: 386

A quick look at the documentation reveals the answer: http://django-compressor.readthedocs.org/en/latest/settings/

django.conf.settings.COMPRESS_ENABLED should be set to True otherwise its opposite to DEBUG

UPDATE

Sorry that's embarrassing, I totally missed the: COMPRESS_ENABLED = True on your settings.

Upvotes: 0

Related Questions