javascript function not accesible

I have a javascript function in a file calles misc.js in my static dir in my django project:


function df () {
    $('#cselect').click(function() { if($(this).prop('checked')==true) { $(':checkbox').prop('checked',true)}
				     { $(':checkbox').prop('checked',false)} } )

in my url I have the following code:

]+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

and in settings:


However, the function is not accesible in my develop console when I load my page. What is wrong?

How are you including that in the page being loaded?
(What do you have in your template to load that file?)

the last line is to check if the function df is accesible.

{% load static %} 
<script src=""></script>
<button class="button is-small is-light" id="cselect"> välj</button>
<script type="text/javascript" src="{% static 'js/misc.js' %}">df</script>

Standard things to check:

Look at your browser’s network tab in the developer tools to verify that a request was issued.

Look for the HTTP request in your server’s console to see if the request was made, and received a 200 and not a 404.

Use your browser’s developer tools console to see if the name for that function was defined.

Note that your attempt to put a reference to the function inside that script tag is usually not going to work, because that will frequently be executed before the http request for the JavaScript file is executed and almost certainly before the response to that request is received and processed. You would need to write a script that can wait until all assets are loaded before running.

It is a 404, it can’t find it, so maybe I need to change my

What directory is that file in your project?

directory struture:


But in your template, you are looking for it in:

which should probably be

ah, that is right. thanks a lot