0

I try to load the bootstrap-datepicker.js (Located: ...\AEB\static\date_picker\js)

    {% load staticfiles %}
<script type="text/javascript" src="{% static "Leaflet_modi.js" %}"></script>
<!-- Files for date time picker---------------------->
<link rel="stylesheet" href="{% static 'date_picker/css/datepicker.css' %}" type = "text/css"/>
<script type="text/javascript" src="{% static "date_picker/js/bootstrap-datepicker.js" %}"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>

<script type="text/javascript">

$(document).ready(function () {
    $('#Start_Date').datepicker({
        format: "dd/mm/yyyy"
    });
});
$(document).ready(function () {
    $('#End_Date').datepicker({
        format: "dd/mm/yyyy"
    });
});

</script>

Here is my project structure:

enter image description here

But I always get the following error message: "Uncaught TypeError: $(...).datepicker is not a function"

But I do not get any 404 (see image below)

enter image description here

Where is my mistake? Thanks for your help.

2
  • pleases show your project tree Commented May 31, 2018 at 13:42
  • So I edited my original post Commented May 31, 2018 at 13:47

2 Answers 2

1

You need to call jquery first,

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
  <script type="text/javascript" src="{% static "Leaflet_modi.js" %}"></script>
 <!-- Files for date time picker---------------------->
 <link rel="stylesheet" href="{% static 'date_picker/css/datepicker.css' %}" type = "text/css"/>
 <script type="text/javascript" src="{% static "date_picker/js/bootstrap-datepicker.js" %}"></script>

 <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
Sign up to request clarification or add additional context in comments.

1 Comment

That is amazing. Thanks a lot :)
0

I thing your routing in false!!

If you have some files like this :

-<project folder>
----<project-config-folder>
--------setting.py
--------    .
--------    .
--------    .
-------<app-name>
-----------views.py
-----------models.py
--------     .
--------     .
--------     .
--------static
--------------posts
--------------------a.jpg
--------   .
--------   .
--------   .

You can use like this to set file path :

<img src="{% static "posts/a.jpg" %}" alt="My image"/>

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.