question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Raise javascript errors

See original GitHub issue

I 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:open
  • Created 7 years ago
  • Reactions:1
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
daradibcommented, Jan 9, 2018

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:

MediaOrderConflictWarning: Detected duplicate Media files in an opposite order:
autocomplete_light/jquery.init.js
admin/js/admin/DateTimeShortcuts.js

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.

1reaction
kigawascommented, Dec 17, 2018

Now you can just use autocomplete_fields since django 2.0.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found