0

I have a django project mysite and app named login

The web page i am opening is

D:\mysite\templates\login\index.html

This html file needs a javascript file (in the same directory) for it to work

The js file is in

D:\mysite\templates\login\d3.js

How to provide this path in the

<script src = "...\d3.js">

in the html file?


I did all this

in my urls.py

from django.contrib.staticfiles.urls import staticfiles_urlpatterns 
urlpatterns += staticfiles_urlpatterns()

in settings.py

STATICFILES_DIRS = ('D:/mysite/templates/login')

then used this in html file

<script src="{{static_url}}/d3.js"></script>

Still doesn't work

1 Answers1

1

Use the django statics module

Then your link will be something like <script src="{{ STATIC_URL }}/d3.js" />

cberner
  • 3,000
  • 3
  • 22
  • 34