I want to connect my
.html
.js
map.html
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
</body>
<script type="javascript" src="map.js"></script>
</html>
map.js
document.write("testing");
.js
.html
views.py
def map(request):
return render(request, 'personal/map.html')
A common CMS convention is to save JavaScript files in a static folder. You save anything that you don't want your template engine messing with there: images, javascript, css, etc.
It looks like you may need to save map.js
at this path:
mysite/personal/static/personal/js/map.js
After that, you'll need to update you script link in your HTML to something like:
<script src="static/js/map.js">
The src
path here isn't relative to where you store the file on your computer, but to the URI that your web server associates with it.
Depending on how you've set things up, you'll need some portion of the new path.
Django has a few ways of linking to static resources, but I'm not familiar enough with the platform to tell you which option you should use.