summaryrefslogtreecommitdiff
path: root/compressor/utils/staticfiles.py
blob: 28026f26bb442b745ad70f58711d4255078b9e1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from __future__ import absolute_import, unicode_literals

from django.core.exceptions import ImproperlyConfigured

from compressor.conf import settings

INSTALLED = ("staticfiles" in settings.INSTALLED_APPS or
             "django.contrib.staticfiles" in settings.INSTALLED_APPS)

if INSTALLED:
    if "django.contrib.staticfiles" in settings.INSTALLED_APPS:
        from django.contrib.staticfiles import finders
    else:
        try:
            from staticfiles import finders  # noqa
        except ImportError:
            # Old (pre 1.0) and incompatible version of staticfiles
            INSTALLED = False

    if (INSTALLED and "compressor.finders.CompressorFinder"
            not in settings.STATICFILES_FINDERS):
        raise ImproperlyConfigured(
            "When using Django Compressor together with staticfiles, "
            "please add 'compressor.finders.CompressorFinder' to the "
            "STATICFILES_FINDERS setting.")
else:
    finders = None  # noqa