Skip to content
Advertisement

JavaScript not found in Django

I am trying to use JavaScript within my Django project. I have made a static folder within my app containing css and js folders, and whilst my css is working my js files are not. Any help would be great, thanks.

HTML:

JavaScript

settings.py:

JavaScript

Advertisement

Answer

You need to give a static directory to the STATICFILE_DIRS setting, not the full path:

JavaScript

And in your template, you need to put double quotes around the static tag, and single quotes inside the tag:

JavaScript

On a side note, I have never seen type="module" on a script tag before, so I’m not sure if that will work. Generally its type="text/javascript"

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement