Sunday, September 8, 2019

Managing links on static files from a static file

Good daytime.
I've spent some time trying to find a solution to my problem, but I still can't.
Here is my problem.
One of my html templates has a link on a javascript file, looking similar to this:
<script type="text/javascript" src='{% static "app_name/script_dir/script_name.js" %}'></script>
The page is returned, when asking the next url:
http://127.0.0.1:8000/app_name/page_name/
The mode is Debug, the static is registered and turned on and the script itself is loaded quite successfully.
But the script is a part of a complete project and it contains some references on other .js and .css files from that project, that are also store locally.
And when script is loading and requesting that other files, the server respond with 404 "Not found", because their references are relative and become like this:
http://127.0.0.1:8000/app_name/page_name/file_relative_path
instead of
/static/file_relative_path
So is there a way to translate such links from a page-relative link to a static-relative link?


Best wishes, Mikhail

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/74c4d0f3-7056-4d67-988c-cafd9e7b0570%40googlegroups.com.

No comments:

Post a Comment