Raise javascript errors
See original GitHub issueI just followed django-autocomplete-light tutorial, and it works very well in local mode.
Only problem is, it shows this kind of error in browser:
Uncaught ReferenceError: jQuery is not defined select2.min.js:1
Uncaught TypeError: Cannot read property 'fn' of undefined autocomplete.init.js:8
Uncaught ReferenceError: jQuery is not defined select2.full.js:17
Uncaught TypeError: $ is not a function select2.js:3
Uncaught SyntaxError: Unexpected identifier :1
This is my base.html
<!DOCTYPE html>
<html>
<head>
<!-- Meta -->
<meta charset="utf-8">
<meta name="keywords" content="HTML5,CSS3,Template" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, maximum-scale=1, initial-scale=1, user-scalable=0" />
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
{% block custom_stylesheet %}
{% endblock %}
</head>
<body>
<!-- HEADER -->
{% include "skeleton/header.html" %}
<!-- /HEADER -->
<!-- MAIN -->
<section>
{% block content %}
{% endblock %}
</section>
<!-- /MAIN -->
<!-- FOOTER -->
{% include "skeleton/footer.html" %}
<!-- /FOOTER -->
<script src="https://code.jquery.com/jquery-2.2.3.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous">
</script>
{% block custom_js %}
{% endblock %}
</body>
</html>
This is my code where autocomplete applied:
{% extends "skeleton/base.html" %}
{% load static %}
{% block content %}
{% crispy form %}
{% endblock %}
{% block custom_js %}
{{ form.media }}
{% endblock %}
What’s wrong with it?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:20 (9 by maintainers)
Top Results From Across the Web
JavaScript Errors Try Catch Throw - W3Schools
When an error occurs, JavaScript will normally stop and generate an error message. The technical term for this is: JavaScript will throw an...
Read more >throw - JavaScript - MDN Web Docs - Mozilla
The throw statement throws a user-defined exception. Execution of the current function will stop (the statements after throw won't be ...
Read more >How to Throw Exceptions in JavaScript - Rollbar
Throwing a generic exception is almost as simple as it sounds. All it takes is to instantiate an exception object—with the first parameter...
Read more >Error handling in JavaScript - TutorialsTeacher
Use throw keyword to raise a custom error. ... You can use JavaScript object for more information about an error. ... Want to...
Read more >A Definitive Guide to Handling Errors in JavaScript - Kinsta
A script error occurs when a third-party script sends an error to your browser. This error is followed by (unknown) because the third-party ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The default date widget in the admin -
AdminDateWidget
- tries to load jQuery and breaks the order jQuery is loaded by dal. So I’m using SelectDateWidget instead which lacks pretty JS. In Django 2.0 I also get this warning:which seems to be caused by
Media.merge
trying to merge two asset lists, one which has autocomplete_light’s assets before admin’s, and the other has admin’s before autocomplete_light’s.Now you can just use
autocomplete_fields
since django 2.0.