[Fixed]-Django not detecting Less file

1👍

All _ROOT directories are about filesystem, all _URL directories are web addresses, like henrikstroem mentioned in comments.

Each _URL directory must match it’s equivalent _ROOT directory on http server side, for example in your web server is configured to serve all files from /your/app/static/ on address http://example.com/static/, that means you shoud configure STATIC_ROOT and STATIC_URL like this:

STATIC_ROOT = "/your/app/static/" # this path must be absolute
STATIC_URL = "/static/" # this url can be relative to your domain or can be full url to your static directiory

Remember, all _ROOT directories must be absolute. You also shouldn’t hardcode full path, but better use os.path functions to let python build that path relative to your settings file.

By default STATIC_PRECOMPILER_ROOT will be equal to STATIC_ROOT and it’s fine, because static precompiler will put all compiled files into subdirectory named COMPILED by default, so it won’t collide with other static files that you have. Also remember that static precompiler won’t serve that files by itself, so it’s better to keep them with static files.

So try to remove STATIC_PRECOMPILER_ROOT from your settings and fix other paths as I described above.

Also in your header you should use:

{% load compile_static %}

So static precompiler can detect your file, compile it and put proper path to compiled file.

Leave a comment