Comments (8)
Trying to find a way to reproduce this, can you check if the image referenced in the CSS files also live under COMPRESS_ROOT?
https://github.com/jezdez/django_compressor/blob/0.5.3/compressor/filters/css_default.py#L10-11
from django-compressor.
The images referenced do live under COMPRESS_ROOT (which I've set to be the same as STATIC_ROOT), but not MEDIA_ROOT.
I'm not sure I understand what the filter you linked to is used for - looks like it's only processing paths that start with MEDIA_ROOT. The image paths in my CSS files are, eg, url('../images/logo.png')
from django-compressor.
Yeah, the code is slightly confusing there, it uses compressor.conf.settins.MEDIA_ROOT which is COMPRESS_ROOT by default. I'm about to change that to be clearer.
It doesn't explain your issue though. I'd be great if you could send me your complete settings and a tree
of your project (feel free to redact any private info) to reproduce the problem.
from django-compressor.
Ah, okay I see.
I've got a pretty involved settings file, so if it's alright I'll just include here the stuff related to caching/media handling.
CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
}
}
MEDIA_ROOT = os.path.join(PROJECT_ROOT, "..", "site_media", "media")
MEDIA_URL = "/site_media/media/"
STATIC_ROOT = os.path.join(PROJECT_ROOT, "..", "site_media", "static")
STATIC_URL = "/site_media/static/"
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT, "static_media"),
os.path.join(PINAX_ROOT, "media", PINAX_THEME),
)
ADMIN_MEDIA_PREFIX = posixpath.join(STATIC_URL, "admin/")
COMPRESS_ROOT = STATIC_ROOT
COMPRESS_URL = STATIC_URL
I'm using django-staticfiles, so before django-compressor is used, all the media is copied from the project/project_root/static_media/
directory out to project/site_media/static
. Here's the project tree:
project/
project_root/
apps/
static_media/
css/
style.css
images/
logo.png
js/
templates/
manage.py
settings.py
site_media/
media/
static/
CACHE/
css/
style.css
images/
logo.png
js/
The CSS files are referred to from the templates with {{ STATIC_URL }}css/style.css
(wrapped with {% compress %}{% endcompress %}
, and the images are referred to from CSS with url('../images/logo.png')
.
If you need anything clarified, let me know. And if this doesn't help find the issue, I can try putting together a very basic project that reproduces the error.
from django-compressor.
Hm, I've worked on compressor a bit over the weekend, would you mind trying the project at http://d.pr/MaO1 with the current develop branch? If you use staticfiles, make sure you use the latest 1.0a4.
from django-compressor.
The develop branch of django-compressor works correctly with both projects (my own and the provided one), but it forces me to specify CACHES_BACKEND = "locmem://"
instead of
CACHES = { 'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
} }
as in the latest Django docs. If I use the settings from the docs, I get: InvalidCacheBackendError: Backend URI must start with scheme://
.
from django-compressor.
Okay, can you try again with 0.6b1, please?
from django-compressor.
Just tried again with 0.6b1 and it's all working great. Thanks for taking care of this!
from django-compressor.
Related Issues (20)
- Slim down package HOT 1
- Add support for django 4.2 HOT 1
- Replace deprecated imp module with importlib HOT 2
- Django's `get_storage_class` is deprecated in 4.2 (Django 5.1 compat.) HOT 5
- Releasing a new version with Django 4.2 support HOT 3
- No way to specify hashing method for JS files? HOT 1
- Disable offline compression for some scripts HOT 5
- Fix tests with Python 3.9.17, 3.10.12 and 3.11.4 HOT 7
- Dependencies are pinned HOT 1
- Dynamic SCRIPT_NAME and compressed assets HOT 8
- Getting more info when `Error parsing template` happens
- Not compatible with django-components HOT 10
- Issue with losing templates in compress command in version >=3.0.
- optional max_workers for compress command HOT 1
- 'Settings' object has no attribute 'COMPRESSORS' HOT 8
- OSSFuzz Integration HOT 4
- 4.4: compressor.exceptions.OfflineGenerationError raised in tests HOT 4
- Django 5.1 compatibility HOT 1
- Offline compression + inlining bug HOT 3
- Compress command: warn or error about context vars?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-compressor.