Reputation: 90
I use JQuery in my django project quite often, and it hasn't been a problem so far. Even in my current project, I use it on multiple pages. But on one page, I get this error in the console:
Uncaught ReferenceError: $ is not defined
This is my JQuery Code:
$(document).ready(function(){
console.log("hello")
})
This is what I imported in my base.html
:
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
Like I said I used JQuery a lot in this project so and it worked fine so far. I also did extend Base.html properly.
What could be the problem?
Upvotes: 0
Views: 1600
Reputation: 26
This error might be caused by these following things:
$
in your consoleTry comparing how you imported jQuery in the other working templates. Are they extensions of the same base template? Are all of your blocks correctly named? Is your script being run after jQuery is imported?
Upvotes: 1