Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: expected str, bytes or os.PathLike object, not NoneType #61

Closed
janieIradar opened this issue Nov 24, 2020 · 5 comments · Fixed by #62
Closed

Error: expected str, bytes or os.PathLike object, not NoneType #61

janieIradar opened this issue Nov 24, 2020 · 5 comments · Fixed by #62

Comments

@janieIradar
Copy link

Hi, I just installed the package and set up according to the documentation by adding 'sri' to INSTALLED_APP, and set USE_SRI equal to True (cause my project still in development), but I still getting this error. I have no idea which part I've done wrong. Please help!

image
image

@RealOrangeOne
Copy link
Owner

Interesting, i'm not seeing anything in that which looks specifically wrong.

Is there any more of a stack trace which tells you which line in the library is the issue? This will likely be in the django logs rather than being shown in the page.

@janieIradar
Copy link
Author

Sorry, here is the stack trace.

Traceback (most recent call last):
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\django\core\handlers\exception.py", line 47, in inner
response = get_response(request)
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\django\core\handlers\base.py", line 179, in _get_respo
nse
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\dashboard\views.py", line 93, in dashboard_page
return render(request, 'dashboard/dashboard.html', context)
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\django\shortcuts.py", line 19, in render
content = loader.render_to_string(template_name, context, request, using=using)
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\django\template\loader.py", line 62, in render_to_stri
ng
return template.render(context, request)
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\django\template\backends\django.py", line 61, in rende
r
return self.template.render(context)
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\django\template\base.py", line 170, in render
return self._render(context)
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\django\template\base.py", line 162, in _render
return self.nodelist.render(context)
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\django\template\base.py", line 938, in render
bit = node.render_annotated(context)
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\django\template\base.py", line 905, in render_annotate
d
return self.render(context)
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\django\template\loader_tags.py", line 150, in render
return compiled_parent._render(context)
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\django\template\base.py", line 162, in _render
return self.nodelist.render(context)
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\django\template\base.py", line 938, in render
bit = node.render_annotated(context)
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\django\template\base.py", line 905, in render_annotate
d
return self.render(context)
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\django\template\library.py", line 192, in render
output = self.func(*resolved_args, **resolved_kwargs)
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\sri\templatetags\sri.py", line 39, in sri_static
"integrity": calculate_integrity(get_static_path(path), algorithm),
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\sri\utils.py", line 27, in get_static_path
return safe_join(settings.STATIC_ROOT, path)
File "C:\Users\janie\Documents\GoTani\dev_gotani\03_Software\02_Backend_Sourcecode\gotani_1.0.0\gotani_site\venv\lib\site-packages\django\utils_os.py", line 17, in safe_join
final_path = abspath(join(base, *paths))
File "C:\Users\janie\AppData\Local\Programs\Python\Python36\lib\ntpath.py", line 76, in join
path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType

@RealOrangeOne
Copy link
Owner

hmm interesting. Looks like that's coming from https://github.com/RealOrangeOne/django-sri/blob/master/sri/utils.py#L27.

Do you have STATIC_ROOT defined in your settings?

@janieIradar
Copy link
Author

No actually, my project currently using STATICFILES_DIRS.

@RealOrangeOne
Copy link
Owner

ah, ok, I see the issue. It looks like it's incorrect to be reading files direct from STATIC_ROOT as I am. It should instead look at those dirs.

There's probably a helper in Django for getting the filesystem path of a static file somewhere, i'll give it a look over the weekend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants