Javascript is not loaded in html in django

In my project,there is a register.html file . the file is given below:

<!DOCTYPE html> 
{% load static %}
<html>
   <head>
      <title>Page Title</title>
    </head> 
    <body> 
      <p>This is only for test.</p> 
    </body>

<script> src= "{% static 'js/register.js' %}" </script>

</html>

Here you can see the javascript part in the last section. This script should be load the register.js file which is exists in app_name/static/js/register.js . But the problem is that the register.js file is not loaded .
The register.js file is given below:
console.log(“this is working”);

when I run this , the console look as that picture which is given below:

Even If I give full path such as <script> src= "/home/name/python/django/python test/app_name/static/js/register.js" </script> then also the error is still remain .
But if I give direct code like <script> console.log("this is test"); </script> then it perfectly worked.
How can I solve this issue?

Try putting the script tag inside the <head> or <body> elements.

1 Like

Already try that but the issue is still remain.

Even If I give full path such as <script> src= "/home/name/python/django/python test/app_name/static/js/register.js" </script> then also the error is still remain .

oh! sorry . I made a mistake . Actually src=… should be inside the tag, i.e. <script src=...> </script> . Now everything is fine.

1 Like