compressor path issue

All,

I am using django-compressor and it is working for my development environment (pure Django) but not my production environment (Django under Apache, hosted by WebFaction). Here are the relevant details:

settings.py:

STATIC_ROOT = "/path/to/my/static/files/"
STATIC_URL = '/static/'
COMPRESS_ENABLED = True
COMPRESS_OFFLINE = True
COMPRESS_ROOT = STATIC_ROOT + "my_app_name/"
COMPRESS_PRECOMPILERS = (
    ('text/less', 'lessc {infile} {outfile}'),
)
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
)

some_template.html:

{% load staticfiles %}
{% load compress %}
<html>
  <head>
    {% compress css %}
      <link rel="stylesheet" type="text/less" media="all" href="{% static 'my_app/less/my_app.less' %}" />
    {% endcompress %}
  </head>
  <body>
    <div class="my_class">hello world</div>
  </body>
</html>

I run python manage.py compress && python manage.py collectstatic to make sure the "my_app.less" file above is compiled, compressed, and copied correctly.

As I said, in my development environment this works fine. The server makes a call to "//localhost:8000/static/CACHE/css/1d4e9429eac4.css" and returns the file at "/path/to/my/static/files/my_app_name/CACHE/css/1d4e9429eac4.css".

But in production, that same URL "//my.domain.com/static/CACHE/css/1d4e9429eac4.css" returns a 404 Not Found error. The file exists locally at "/path/to/my/static/files/my_app_name/CACHE/css/1d4e9429eac4.css".

I've noticed that if I manually goto "//my.domain.com/static/my_app_name/CACHE/css/1d4e9429eac4.css" (note the addition of "my_app_name") then the file is found.

My question is, why is it behaving differently on the two servers? Which is the correct behavior? And how can I ensure that compression works in both cases?

Thanks.

链接地址: http://www.djcxy.com/p/71098.html

上一篇: 基于另一个表删除表中的所有行

下一篇: 压缩机路径问题