Django-compressor + compresses files less, but refers to source files

I have a django 1.4.2 application with django-compressor 1.2 used to compress a smaller file.

I have fewer files in /static/css/home.less application. It outputs fewer files under static / CACHE / css / 5208013a00a2.css

When running locally (Debug = True, files are served by django), I get the correct answer. the following output in the html (template) file:

<link rel="stylesheet" href="/static/CACHE/css/5208013a00a2.css" type="text/css"> 

When running in deployment (Apache serves files) I have a bad answer. the following output in my html file:

 <link type="text/less" rel="stylesheet" href="/adduplicator/static/css/home.less" charset="utf-8"> 

Files are created when deployed under static / CACHE / css / 5208013a00a2.css , so I assume there are no resolution problems. I am not mistaken in magazines.

some settings from settings.py:

 COMPRESS_PRECOMPILERS = ( ('text/coffeescript', 'coffee --compile --stdio'), ('text/less', 'lessc {infile} {outfile}'), ) STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'compressor.finders.CompressorFinder', ) 

Deployment is done through the fabric and creates the application under virtual env.

+4
source share
3 answers

I believe

('text/less', 'lessc {infile} {outfile}'),

it should be

('text/less', 'lessc {infile} > {outfile}'),

since without redirection lessc will compile to standard output.

0
source

This may or may not apply to the original poster, but I experienced the same error (without using files without a link instead of the generated CSS), and that was because I recently installed Django to run as a regular user instead of the root, and therefore , does not have the right to write to the cache folder created by him as root. chown -R myuser:mygroup static/cache solved the problem.

0
source

I have a similar problem, my setup is almost identical to yours (using apache, debug = False, etc.) and hasn't resolved it yet. I found that if I manually started the compress (python manage.py compress), it will solve the problem, but it will only solve it temporarily. After 6-12 hours, the problem will recur.

There is nothing dynamic in the .css / .js files I am compressing. I use the django compressor as a means of precompiling my lessc and coffeescript.

I hope you found a workaround last fall when you encountered this problem - for those who have the same problem, try manually starting the compress. I don't know why this helps, since the files are already in CACHE, but for some reason it does (temporarily). I will update when it decides.

EDIT: The problem has not recurred in the last 12 days. I still sketched a little that there is a problem, and I did not understand the resolution, but so far it works, so I focus on other things. If you have a problem of this nature, please write or comment.

Recommended action when this problem occurs:

  • Make sure the files are generated in the CACHE directory
  • Look at the ownership of the CACHE files and directories and, if necessary, run them
  • Look at the timestamps of files in CACHE, make sure they are reasonable.
  • Run the build and compress manually and then restart the server (kill and restart if you use python runningerver or sudo service restart apache2 or other equivalent)
0
source

Source: https://habr.com/ru/post/1447190/


All Articles