6

我刚刚将 django-compressor 安装到我的项目中,并且收到以下错误消息。

TemplateSyntaxError at / Caught UncompressableFileError while rendering: 'js/jquery-1.7.2.min.js' 无法在 COMPRESS_ROOT '/Users/taelimoh/Dropbox/gluwa-git/static' 或静态文件中找到。

当我尝试压缩 css 文件时也会发生这种情况。

当然,这些文件在那里,当我不尝试使用 django-compressor 压缩它们时它工作正常。

下面是我的模板

...
    {% compress js %}
        <!--Javascripts-->
        <!--Libraries-->
        <script type="text/javascript" src="/static/js/jquery-1.7.2.min.js"></script>
    {% endcompress %}
...

这是我的 settings.py

COMPRESS_ENABLED = True

STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.admin',
    'django.contrib.admindocs',
    'django.contrib.humanize',
    ##############################################
    'appconf',# required by django-compressor
    'versiontools',# required by django-compressor
    'compressor',#https://github.com/jezdez/django_compressor
    ...
)

我正在使用谷歌应用引擎,我的 django 版本是 1.3。该问题是在我的开发服务器上产生的。

4

2 回答 2

2

这可能有点晚了,但文档指出,app.yaml应用程序无法读取任何在您的静态处理程序中配置的文件。值得庆幸的是,还有一个开关可以让您的应用程序读取这些文件。你可以在这里阅读。本质上,你会想要这样做

handlers:
- url: /static
- static_dir: staticfiles
- application_readable: true

在你的app.yaml(注意application_readable)。我为此挣扎了一段时间,因为os.path.exists总是失败。希望这可以帮助。

于 2014-07-17T00:15:23.143 回答
0

GAE 应用程序对文件没有写入权限。如果 Django-compressor 试图将压缩文件写入文件系统,那将会失败。

于 2012-10-08T05:10:54.630 回答