django-sass-processor
django-sass-processor copied to clipboard
sequence item 1: expected str instance, WindowsPath found
I am using this package, on Windows. It worked correctly for some time and then I started to receive this error:
"sequence item 1: expected str instance, WindowsPath found"
The back trace shows the error here: <link href="{% sass_src 'css/main.scss' %}" rel="stylesheet" type="text/x-scss" /> in base.html from which all other templates extend. Looking further down the line in sass.py, line 640, it is trying to join the paths. Python must have a WindowsPath object or something. Any recommendation on how to fix this issue without messing with sass.py?
I was able to move everything to Linux and it is indeed a Windows specific bug.
I still have that exact problem and can not move to linux. Are there workarounds or solutions I can implement on my end?
EDIT: I did print(include_paths) on line 640, and the WindowsPath was pointing to node_modules, which I had set using
SASS_PROCESSOR_INCLUDE_DIRS = [
BASE_DIR / 'node_modules',
]
Since I'm not actually using bootstrap via npm, I got rid of that and now the scss compilation appears to be working. Probably using os.path instead of pathlib in settings.py would also have done the trick.
I think BASE_DIR is an instance of pathlib.Path in settings files generated by recent versions of django.
If the lib does not support them, you need to convert to str explicitly (meaning str(BASE_DIR / 'node_modules'),)
(btw it seems strange to process the whole node_modules! usually there would be a build step to produce a specific bundle or separate files for your app)
The only part where SASS_PROCESSOR_INCLUDE_DIRS is used is here.
There a potential pathlib.Path object is converted to a string anyway. I'm wondering why you don't receive a string.