Reputation: 974
I'm teaching myself Django, and decided to try out some JS functionality. I included a simple text-changing function (from w3schools) in a JS script to try things out. The app is blog
, and the JS script lives in blog/static/blog/test.js
. There's only one function in there:
function myFunction() {
document.getElementById("demo-btn").innerHTML = "Text changed.";
}
Which is linked to a button in blog/templates/blog/post_list.html
, id="demo-btn"
.
Website live here: http://andreyito.pythonanywhere.com
It works fine on my localhost, but when I push it to pythonanywhere
, nothing happens (clicking on the Click me
button is supposed to change the text just above the button.)
This feels like a minor thing that I'm leaving out, but I haven't been able to easily troubleshoot this. Repo here:https://github.com/Don86/djgirls
Upvotes: 0
Views: 346
Reputation: 52028
Your test.js
file is not loading in the pythonanywhere hosting:
You can see their documentation on how they work with static files. Also maybe you did not run python manage.py collectstatic
which loads the file in the static directory. Please see the documentation for more details. Also you can check how they setup the static files in this documentation.
Upvotes: 1