Django compressor and clevercss with absolute urls

When using django, compress and clevercss, I set my css url to an absolute path. Clevercss then passes the path to the .ccss file without the COMPRESS_ROOT prefix (absolute path). When I set my css url to a relative path, clevercss processes the ccss files, but the browser correctly looks for relatively hosted css files (e.g. mywebsite.com/profile/user/1/css/stylesheet.css)

The compressor, however, uses MEDIA_ROOT when the css link is a relative URL, but not when an absolute URL is used. This leads to an unsuccessful effect of my css, which is either processed by clevercss, or not accessible by the browser (if only on the main page), or clevercss does not have access to files (due to the use of an absolute URL). Oddly enough, the examples offered by http://github.com/mintchaos/django_compressor use absolute URLs for css paths.

I think I'm doing something wrong here, but I'm not sure where it could be, and I spent many hours searching. I also run this locally through. /manage.py runningerver and serve some static files (images) through django. (this is good for my local development).

+3
source share
1 answer

I cannot speak specifically about the django compressor; but I was dealing with finding a good automatic compression solution for the CSS and JS files of my Django web applications. I am currently using django-static. It was very easy to configure and use, IMO. I was having problems with django-compress (other than django-compress) when I decided to try django-static. So far it was great. Perhaps worth checking out. It can be found here: http://github.com/peterbe/django-static .

+2
source

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


All Articles