0

I am trying to load the jQuery files to the Django. But its not working for me. When I write the code inside the script tag inside the Head it works perfectly. I wrote the code in a file called main.js

  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js">
   </script>
  <link rel="text/javascript" href="{% static 'js/main.js' %}">

This is my static path in settings

 STATIC_URL = '/static/'

How can I load the jQuery file in django?

1 Answer 1

1

HTML's link is used to load stylesheet -- CSS not JavaScript file.

You have to load javascript with script tag.

so like this:

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

REF: https://developer.mozilla.org/en/docs/Web/HTML/Element/script

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.