Code Monkey home page Code Monkey logo

Comments (8)

jezdez avatar jezdez commented on July 30, 2024

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.

johnthedebs avatar johnthedebs commented on July 30, 2024

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.

jezdez avatar jezdez commented on July 30, 2024

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.

johnthedebs avatar johnthedebs commented on July 30, 2024

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.

jezdez avatar jezdez commented on July 30, 2024

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.

johnthedebs avatar johnthedebs commented on July 30, 2024

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.

jezdez avatar jezdez commented on July 30, 2024

Okay, can you try again with 0.6b1, please?

from django-compressor.

johnthedebs avatar johnthedebs commented on July 30, 2024

Just tried again with 0.6b1 and it's all working great. Thanks for taking care of this!

from django-compressor.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.