0👍
Must Use static path so django can server js file
Project Name
app Name
static
js
css
img
0👍
The problem is that Django renders the html based on what you declare in the context object in your views in Python. Django doesn’t know anything about NPM, NodeJS and the node_modules
folder.
Generally when you use npm to install packages is beacuse you are using them in a NodeJS project that in the end is gonna be converted in a vanilla JS file without dependencies, to be hosted.
That’s why install Chart.js with npm it’s not gonna work, because it will be stored in a node_modules folder, and Django doesn’t know what to do with that. But when you use a cdn you are almost embedding the dependency inside the html, and now it can be referenced in all the JS scripts after it declaration.
I hope that explanation will help you, if there is something that you think that is no well explained, please, let me know.