Reputation: 147
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:
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)
Where is my mistake? Thanks for your help.
Upvotes: 0
Views: 1331
Reputation: 113
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>
Upvotes: 1
Reputation:
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"/>
Upvotes: 0