django-static-precompiler icon indicating copy to clipboard operation
django-static-precompiler copied to clipboard

compilestatic broken on windows directory names.

Open shaladi opened this issue 6 years ago • 1 comments

I discovered this bug while running on windows. In compilestatic.py (lines 29 and 30) it does this:

if path.startswith("/"):
    path = path[1:]

This obviously wouldn't work for windows because it uses backslashes. And I was hitting a bug down the line where os.path.join was returning an absolute path instead of merging it with STATIC_ROOT.

I added the fix for this case as:

if path.startswith("/") or path.startswith("\\"):
    path = path[1:]

Which fixed the problem. But I noticed this assumption of the unix separator is done in more places (e.g. watch.py) in the codebase and may require a bigger refactoring to make sure everything works on windows.

shaladi avatar Jan 01 '19 21:01 shaladi

Hello @shaladi

Could you provide some sample code of how you use the compile template filter?

andreyfedoseev avatar Jan 14 '21 16:01 andreyfedoseev